From Seaborn I generate two separate AxesSubplots. I then get figures from those two subplots separately. I would expect that two objects would not magically interfere with each other without some kind of method being invoked that would make them do that. Why is this broken?

axsp0 = sns.distplot(cas_brs_min['dist'].dropna())
axsp1 = sns.distplot(pd.Series(np.log(cas_brs_min['dist'].dropna()), name='log(dist)'))

axsp0.get_figure().savefig('hist_dist.png')
axsp1.get_figure().savefig('hist_log_dist.png')

´┐╝What I get is the following:

enter image description here

When I believe I should be getting:

enter image description here enter image description here

I am also aware that there exists a object oriented interface for Matplotlib, although it doesn't seem anyone uses it in any tutorials. If I wanted to create a pairplot for this, how would I do that? All I see is f, ax = plt.pairplot(2); ax[0].plot(...); which doesn't seem to interface with anything I can do in Seaborn, which generates plots that I would seemingly have to assign?

1 Answers

1
ImportanceOfBeingErnest On

plt.figure() creates a new figure.

plt.figure()
axsp0 = sns.distplot(c...)
plt.figure()
axsp1 = sns.distplot(p...)

If you feel this doesn't give you enough control, you can create the axes to plot to and supply it to seaborn

fig0, ax0 = plt.subplots()
axsp0 = sns.distplot(c..., ax=ax0)
fig1, ax1 = plt.subplots()
axsp1 = sns.distplot(p..., ax=ax1)