如何使用Matplotlib 在子图中绘制多个Seaborn联合图?
要绘制多个Seaborn联合图,我们可以使用jointplot()方法。
步骤
向当前图形添加一个子图。
使用某些键创建一个字典。
使用Pandas创建一个数据帧。
使用 jointplot()方法制作联合图。
要绘制曲线,请使用plot()方法。
要显示图形,请使用show()方法。
示例
from matplotlib import pyplot as plt
import pandas as pd
import seaborn as sns
plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True
plt.subplot()
d = {
'y=1/x': [1 / i for i in range(1, 10)],
'y=x': [i for i in range(1, 10)],
'y=x^2': [i * i for i in range(1, 10)],
'y=x^3': [i * i * i for i in range(1, 10)]
}
df = pd.DataFrame(d)
jg = sns.jointplot(data=df)
jg.plot(sns.scatterplot, sns.histplot)
plt.show()输出

广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C语言编程
C++
C#
MongoDB
MySQL
Javascript
PHP