.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/plotting/_regplot.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code or to run this example in your browser via Binder .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_plotting__regplot.py: ====================== 6.5 regression plot ====================== .. GENERATED FROM PYTHON SOURCE LINES 7-16 .. code-block:: default # sphinx_gallery_thumbnail_number = -2 import numpy as np from easy_mpl import regplot import matplotlib.pyplot as plt from easy_mpl.utils import version_info version_info() .. rst-class:: sphx-glr-script-out .. code-block:: none {'easy_mpl': '0.21.4', 'matplotlib': '3.8.4', 'numpy': '1.26.4', 'pandas': '1.5.3', 'scipy': '1.13.1'} .. GENERATED FROM PYTHON SOURCE LINES 17-25 .. code-block:: default rng = np.random.default_rng(313) x = rng.uniform(0, 10, size=100) y = x + rng.normal(size=100) _ = regplot(x, y) .. image-sg:: /auto_examples/plotting/images/sphx_glr__regplot_001.png :alt: regplot :srcset: /auto_examples/plotting/images/sphx_glr__regplot_001.png, /auto_examples/plotting/images/sphx_glr__regplot_001_2_0x.png 2.0x :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 26-27 customizing marker style .. GENERATED FROM PYTHON SOURCE LINES 27-30 .. code-block:: default _ = regplot(x, y, marker_color='white', scatter_kws={'marker':"D", 'edgecolors':'black'}) .. image-sg:: /auto_examples/plotting/images/sphx_glr__regplot_002.png :alt: regplot :srcset: /auto_examples/plotting/images/sphx_glr__regplot_002.png, /auto_examples/plotting/images/sphx_glr__regplot_002_2_0x.png 2.0x :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 31-32 another example by increasing the `marker size` .. GENERATED FROM PYTHON SOURCE LINES 32-36 .. code-block:: default _ = regplot(x, y, marker_color='crimson', marker_size=35, scatter_kws={'marker':"o", 'edgecolors':'black'}) .. image-sg:: /auto_examples/plotting/images/sphx_glr__regplot_003.png :alt: regplot :srcset: /auto_examples/plotting/images/sphx_glr__regplot_003.png, /auto_examples/plotting/images/sphx_glr__regplot_003_2_0x.png 2.0x :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 37-38 customizing line style .. GENERATED FROM PYTHON SOURCE LINES 38-43 .. code-block:: default _ = regplot(x, y, marker_color='dodgerblue', marker_size=35, scatter_kws={'marker':"o"}, line_color='dimgrey', line_style='--', line_kws={'linewidth':3}) .. image-sg:: /auto_examples/plotting/images/sphx_glr__regplot_004.png :alt: regplot :srcset: /auto_examples/plotting/images/sphx_glr__regplot_004.png, /auto_examples/plotting/images/sphx_glr__regplot_004_2_0x.png 2.0x :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 44-45 customizing fill color .. GENERATED FROM PYTHON SOURCE LINES 45-49 .. code-block:: default _ = regplot(x, y, marker_color='crimson', marker_size=40, scatter_kws={'marker':"o", 'edgecolors':'black'}, fill_color='teal') .. image-sg:: /auto_examples/plotting/images/sphx_glr__regplot_005.png :alt: regplot :srcset: /auto_examples/plotting/images/sphx_glr__regplot_005.png, /auto_examples/plotting/images/sphx_glr__regplot_005_2_0x.png 2.0x :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 50-51 hiding confidence interval .. GENERATED FROM PYTHON SOURCE LINES 51-55 .. code-block:: default _ = regplot(x, y, marker_color='crimson', marker_size=40, scatter_kws={'marker':"o", 'edgecolors':'black'}, ci=None, line_color='olive') .. image-sg:: /auto_examples/plotting/images/sphx_glr__regplot_006.png :alt: regplot :srcset: /auto_examples/plotting/images/sphx_glr__regplot_006.png, /auto_examples/plotting/images/sphx_glr__regplot_006_2_0x.png 2.0x :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 56-58 multiple regression lines with customized marker, line and fill style .. GENERATED FROM PYTHON SOURCE LINES 58-75 .. code-block:: default cov = np.array( [[1.0, 0.9, 0.7], [0.9, 1.2, 0.8], [0.7, 0.8, 1.4]] ) data = rng.multivariate_normal(np.zeros(3), cov, size=100) ax = regplot(data[:, 0], data[:, 1], line_color='orange', marker_color='orange', marker_size=35, fill_color='orange', scatter_kws={'edgecolors':'black', 'linewidth':0.8, 'alpha': 0.8}, show=False, label="data 1") _ = regplot(data[:, 0], data[:, 2], line_color='royalblue', ax=ax, marker_color='royalblue', marker_size=35, fill_color='royalblue', scatter_kws={'edgecolors':'black', 'linewidth':0.8, 'alpha': 0.8}, show=False, label="data 2", ax_kws=dict(legend_kws=dict(loc=(0.1, 0.8)))) plt.show() .. image-sg:: /auto_examples/plotting/images/sphx_glr__regplot_007.png :alt: regplot :srcset: /auto_examples/plotting/images/sphx_glr__regplot_007.png, /auto_examples/plotting/images/sphx_glr__regplot_007_2_0x.png 2.0x :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 2.345 seconds) .. _sphx_glr_download_auto_examples_plotting__regplot.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: binder-badge .. image:: images/binder_badge_logo.svg :target: https://mybinder.org/v2/gh/AtrCheema/python-seekho/master?urlpath=lab/tree/notebooks/auto_examples/plotting/_regplot.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: _regplot.py <_regplot.py>` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: _regplot.ipynb <_regplot.ipynb>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_