我有两个matplotlib(seaborn)图形对象,它们都是在不同的ipython单元格中制作的。
#One Cell
fig_1_object = sns.factorplot(y='freq',x='d_fam',col='easy_donor',kind="bar",data=collection_d_fam)
fig_1 = fig_1_object.fig
#Two Cell
fig_2_object = sns.factorplot(y='freq',x='d_fam',col='easy_donor',kind="bar",data=collection_c_fam)
fig_2 = fig_2_object.fig
如何在同一个单元格中一个接一个地“显示”它们。我打开了matplotlib inline。
#third cell
fig_1
fig_2
>>Only shows fig_2
答案 0 :(得分:2)
您只需要从display
模块中导入IPython.display
函数:
from IPython.display import display
import seaborn
%matplotlib inline
g1 = seaborn.factorplot(**options1)
g2 = seaborn.factorplot(**options2)
display(g1)
display(g2)
答案 1 :(得分:0)
那呢?
plt.figure(1, figsize=(5,10))
plt.subplot(211)
# Figure 1
sns.factorplot(y='freq',x='d_fam',col='easy_donor',kind="bar",data=collection_d_fam)
plt.subplot(212)
# Figure 2
sns.factorplot(y='freq',x='d_fam',col='easy_donor',kind="bar",data=collection_c_fam)
答案 2 :(得分:0)
您可以在每个图像后使用plt.show():
sns.factorplot(y='freq',x='d_fam',col='easy_donor',kind="bar",data=collection_d_fam)
plt.show()
sns.factorplot(y='freq',x='d_fam',col='easy_donor',kind="bar",data=collection_c_fam)
plt.show()
答案 3 :(得分:0)
//For displaying 2 or more fig in the same row or columns :-
fig, axs = plt.subplots(ncols=2,nrows=2,figsize=(14,5))
//The above (ncols) take no of columns and (nrows) take no of rows and (figsize) to enlarge the image size.
sns.countplot(x=data['Rating'],palette="rocket",ax=axs[0][0])
sns.countplot(x=data['Rating'][0:50],palette="rocket",ax=axs[1][0])
sns.countplot(x=data['Rating'],palette="rocket",ax=axs[0][0])
sns.countplot(x=data['Rating'][0:50],palette="rocket",ax=axs[1][0])`
//Here in any plot u want to plot add **ax** and pass the position and you are ready !!!