With matplotlib 1.4.0 the cla() method for the twinx axes also clears the primary axes. With matplotlib 1.3.1 the method only clears the twinx axes as expected. I have a much longer program where the twinx axes must be cleared while retaining
the primary axis plot. I would prefer not to replot the entire graph each time the twinx axes change. You can see this by adding the cla method to the matplotlib web site example, two_scales.py, shown below.
I have matplotlib installed via the anaconda package. Matplotlib 1.4.0 is from anaconda 2.1.0. Matplotlib 1.3.1 is from 1.9 versions of the anaconda package.
Linux gamow 3.2.0-4-amd64 #1 SMP Debian 3.2.60-1+deb7u3 x86_64 GNU/Linux
Same cla() result on osX 10.9.4.
Same result for backends Qt4Agg and TkAgg; the cla() method cleared both axes.
I also tried various other options such as setting ax2.hold(False) prior to replotting ax2. However, once again ax1 was cleared. The ax2 clear commands seem to apply to the ax1 axis as well??? These options worked as expected for the
earlier matplotlib version, clearing only the ax2 axis.
Here’s the code: if you execute the code, you should see a blank figure with the cla() included and the usual two graphs without the cla() method.
I would appreciate any help; this looks like a bug in the latest version of matplotlib.
I could not find any reference to this problem in earlier posts.