Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Description
In the plot below, each axes is yaxis-shared with the axes in the same column.
In each case, I'll start by setting the top yaxis to use a log-base-2 scale.
- In the left column, I then call cla() on thetop axis.
- In the right column, I then call cla() on thebottom axis.
In every case, the top-left text indicates the scale and formatter used by that axis before the call to cla(), the top-right text indicates the scale and formatter used after the call to cla().
In column 1, the call to cla() on the top axis reset both the scale to linear and the formatter to the default formatter. On the bottom axis, the scale was not reset, but the formatter was.
In column 2, the call to cla() on the bottom axis reset the formatter to the default formatter, but did set the scale to log10(!). The top axis had its scale kept and its formatter reset (similarly to column 1 bottom).
I'm not sure what the correct behavior should be but it's likely not the current one.
Script:
from pylab import *mem = {}def remember_scale(ax, title_loc): scale = ax.yaxis._scale fmt = type(ax.yaxis.get_major_formatter()).__name__ if scale.name == "linear": mem[ax, title_loc] = f"linear\n{fmt}" elif scale.name == "log": mem[ax, title_loc] = f"log{scale.base}\n{fmt}" else: mem[ax, title_loc] = "oops"fig, axs = plt.subplots(2, 2, sharey="col")axs[0, 0].set_yscale("log", basey=2)remember_scale(axs[0, 0], "left")remember_scale(axs[1, 0], "left")axs[0, 0].cla()remember_scale(axs[0, 0], "right")remember_scale(axs[1, 0], "right")axs[0, 1].set_yscale("log", basey=2)remember_scale(axs[0, 1], "left")remember_scale(axs[1, 1], "left")axs[1, 1].cla()remember_scale(axs[0, 1], "right")remember_scale(axs[1, 1], "right")for (ax, title_loc), scale in mem.items(): ax.set_title(scale, loc=title_loc)plt.show()
Noted while reviewing#12818 (digging into#12818 (comment)).
mpl 3.0.2 / Py3.7 / Arch Linux