0

Continuation from this question: How can I display and update two matplotlib plots in the same window at the same time?

Previous solution hasn't fixed all plot updating issues. Though "plt" can be replaced with self.comparison_figure1 when using tight_layout(), the same cannot be done when using cla() to clear the plot. As a result my second graph will be cleared and updated when I choose other options from the dropdown menu, but the first graph won't be cleared and updated because "plt" no longer references to the first graph.

Portion of Code where I'm using cla():

sns.set(style="whitegrid")
plt.cla()
ax = self.comparison_figure2.add_subplot(111)
.....

I can post more code if you need it!

2 Answers2

0

cla() is used to clear axes and can't be used with figures.

clf() is used to clear figures.

So instead of:

plt.cla()

Use:

figure.clf()
0

cla

cla() clears an axes. The equivalent of plt.cla() is

ax.cla()
# or
ax.clear()

with ax being a specific matplotlib.axes.Axes.

clf

clf clears a figure. The equivalent of plt.clf() is

fig.clf()
# or
fig.clear()

with fig being a matplotlib.figure.Figure.

ImportanceOfBeingErnest
  • 321,279
  • 53
  • 665
  • 712