Closed
Description
Consider
from pylab import *
from datetime import date
fig, axs = plt.subplots(1, 2, sharex=True)
axs[1].remove()
axs[0].plot([date(2000, 1, 1), date(2000, 2, 1)], [0, 1])
plt.show()
i.e. the call to axs[1].remove()
prevented the axs[0] from acquiring the correct tick formatter and locator.
Interestingly, using fig.delaxes(axs[1])
doesn't exhibit the same bug.
Looks like the problem comes from
def _remove_ax(self, ax):
def _reset_loc_form(axis):
axis.set_major_formatter(axis.get_major_formatter())
axis.set_major_locator(axis.get_major_locator())
axis.set_minor_formatter(axis.get_minor_formatter())
axis.set_minor_locator(axis.get_minor_locator())
def _break_share_link(ax, grouper):
siblings = grouper.get_siblings(ax)
if len(siblings) > 1:
grouper.remove(ax)
for last_ax in siblings:
if ax is not last_ax:
return last_ax
return None
self.delaxes(ax)
last_ax = _break_share_link(ax, ax._shared_y_axes)
if last_ax is not None:
_reset_loc_form(last_ax.yaxis)
last_ax = _break_share_link(ax, ax._shared_x_axes)
if last_ax is not None:
_reset_loc_form(last_ax.xaxis)
where the call to set_major_formatter
(etc.), which basically call formatter.set_axis(axis)
(to update the axis seen by the formatter) also make Matplotlib believe that we had a user-provided formatter (isDefault_majloc = False, etc.) which should not be overridden by the unit framework.
mpl master (ca. 3.0.2)