在同一个 ipython 单元格中渲染两个 seaborn 图形对象
render two seaborn figure objects in same ipython cell
我有两个 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
我怎样才能"show"他们一个接一个地在同一个牢房里。我打开了 matplotlib inline。
#third cell
fig_1
fig_2
>>Only shows fig_2
您只需从 IPython.display
模块导入 display
函数:
from IPython.display import display
import seaborn
%matplotlib inline
g1 = seaborn.factorplot(**options1)
g2 = seaborn.factorplot(**options2)
display(g1)
display(g2)
这个呢?
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)
您可以在每张图片后使用 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()
//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 !!!
我有两个 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
我怎样才能"show"他们一个接一个地在同一个牢房里。我打开了 matplotlib inline。
#third cell
fig_1
fig_2
>>Only shows fig_2
您只需从 IPython.display
模块导入 display
函数:
from IPython.display import display
import seaborn
%matplotlib inline
g1 = seaborn.factorplot(**options1)
g2 = seaborn.factorplot(**options2)
display(g1)
display(g2)
这个呢?
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)
您可以在每张图片后使用 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()
//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 !!!