When plotting successive charts in a single Python script, plt.clf()
does not reverse the effect of plt.gcf().subplots_adjust(bottom=0.5)
. The first chart is adjusted to allow x-axis labels more display space, but this change persists into the second chart. How can one plot the second chart in dist()
to look normal? Even calling sns.set()
or re-importing plt
in the function dist()
or after box_adj()
is called didn't seem to fix the issue.
import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np
def box_adj():
tips = sns.load_dataset("tips")
ax = sns.boxplot(x="day", y="total_bill", hue="smoker",
data=tips, palette="Set3")
plt.gcf().subplots_adjust(bottom=0.5)
plt.savefig('box.png')
plt.clf()
def dist():
ax = sns.distplot(np.random.randn(1000), kde=False)
plt.savefig('dist.png')
plt.clf()
if __name__ == "__main__":
box_adj()
dist()