Reputation: 68
Graph titles are printed one by one. How can I solve this problem??
This is my code.
plt.figure(figsize=(25,10))
plt.subplots_adjust(left=0.125, bottom=0.1, right=0.9, top=0.9, wspace=0.2, hspace=0.4)
n = 1
for idx, i in enumerate(top_10_df_event_copy['Code'].unique()):
top_10_df_event_copy_list[i] = pd.Series(winsorize(top_10_df_event_copy_list[i].values, limits=[0, 0.1]))
stl = seasonal_decompose(top_10_df_event_copy_list[i].values, freq=3)
plt.title(f"{i}", fontsize=15)
ax = plt.subplot(4,3,n)
ax.plot(stl.seasonal + stl.trend)
ax.plot(stl.observed, color='red', alpha=0.5)
n += 1
print(i)
plt.show()
i = [90001302, 90001341, 90001441, 90001443, 90001521, 90001541, 90001542, 90001582, 90001602, 90001622]
Finally print(i)
90001302 90001341 90001441 90001443 90001521 90001541 90001542 90001582 90001602 90001622
but graph is printed like this picture.
There are 10 titles in 10 graphs, but in reality only 9 titles are output in 10 graphs.
plz help..
Upvotes: 0
Views: 34
Reputation: 68146
Use the object-oriented interface to set the titles instead of the pyplot state machine:
from matplotlib import pyplot
fig = pyplot.figure(figsize=(25,10))
for i in range(10):
ax = fig.add_subplot(4, 3, i+1)
ax.set_title(f"This is axes #{i+1}")
fig.subplots_adjust(left=0.125, bottom=0.1, right=0.9, top=0.9, wspace=0.2, hspace=0.4)
Upvotes: 1