我更喜欢使用matplotlibOOP风格:
f, axarr = plt.subplots(2, sharex=True)
axarr[0].plot(...)
axarr[1].plot(...)
Run Code Online (Sandbox Code Playgroud)
这样可以更轻松地跟踪多个图形和子图.
问题:如何使用seaborn这种方式?或者,如何将此示例更改为OOP样式?如何将seaborn绘图函数描述为lmplot哪个Figure或哪个Axes绘图?
我在将Seaborn Jointplot放在多列中时遇到了问题subplot.
import pandas as pd
import seaborn as sns
df = pd.DataFrame({'C1': {'a': 1,'b': 15,'c': 9,'d': 7,'e': 2,'f': 2,'g': 6,'h': 5,'k': 5,'l': 8},
'C2': {'a': 6,'b': 18,'c': 13,'d': 8,'e': 6,'f': 6,'g': 8,'h': 9,'k': 13,'l': 15}})
fig = plt.figure();
ax1 = fig.add_subplot(121);
ax2 = fig.add_subplot(122);
sns.jointplot("C1", "C2", data=df, kind='reg', ax=ax1)
sns.jointplot("C1", "C2", data=df, kind='kde', ax=ax2)
Run Code Online (Sandbox Code Playgroud)
注意如何只将一部分jointplot放置在子图内,其余部分留在另外两个图框内.我想要的是distributions同时插入内部subplots.
有人能帮忙吗?