I am trying to resize the figure when using matplotlib. My code:
%matplotlib notebook
from ipywidgets import interact
@interact(exporter=df.columns.values)
def myplot(exporter):
plt.close() # Close a figure window
plt.cla() # Clear the current axes
plt.clf() # Clear the current figure
x_ticks = np.arange(len(df))
x_labels = [str(date).split("T")[0] if i % 3 == 0 else "" for i, date in enumerate(df.index.values)]
plt.figure(figsize=(10, 8))
plt.plot(x_ticks, df[exporter].values)
plt.title(exporter)
plt.xticks(rotation=45, ticks=x_ticks, labels=x_labels)
However, I'm getting 2 figures instead of one. Below is the output:
How to fix this issue?
question from:
https://stackoverflow.com/questions/65888480/plt-figure-followed-by-plt-plot-generate-2-figures-in-matplotlib-python 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…