It is seaborn that wraps matplotlib, but drawing functions such as seaborn.distplot
refer to the Axes object that is created globally when matplotlib is imported by default.
By passing the individually created Axes object to the ax keyword argument as shown below, you can refer to this.
python
import matplotlib.pyplot as plt
import seaborn as sns
fig = plt.figure()
ax1 = fig.add_subplot(1, 1, 1) #Explicitly create Axes
sns.distplot(data, ax=ax1) #Refer to ax1
By the way, the default behavior is equivalent to: plt.gca ()
returns the (currently active) globally referenced Axes object.
sns.distplot(data, ax=plt.gca())
Recommended Posts