jwillis0720 jwillis0720 - 3 months ago 19
Python Question

render two seaborn figure objects in same ipython cell

I have two matplotlib (seaborn) figure objects both made in different ipython cells.

#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


How can I "show" them one after another in the same cell. I have matplotlib inline turned on.

#third cell
fig_1
fig_2
>>Only shows fig_2

Answer

You just need to import the display function from the IPython.display module:

from IPython.display import display
import seaborn

%matplotlib inline

g1 = seaborn.factorplot(**options1)
g2 = seaborn.factorplot(**options2)

display(g1)
display(g2)
Comments