jwillis0720 jwillis0720 - 1 year ago 95
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
>>Only shows fig_2

Answer Source

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)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download