6.5 regression plot
Note
Click here to download the full example code or to run this example in your browser via Binder
6.5 regression plot#
# 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()
{'easy_mpl': '0.21.4', 'matplotlib': '3.8.2', 'numpy': '1.26.3', 'pandas': '1.5.3', 'scipy': '1.11.4'}
customizing marker style
another example by increasing the marker size
customizing line style
customizing fill color
hiding confidence interval
multiple regression lines with customized marker, line and fill style
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()
Total running time of the script: ( 0 minutes 2.581 seconds)