Marcela Rodrigues Marcela Rodrigues - 1 month ago 11
Python Question

mpl_toolkits.axes_grid1.axes_divider.LocatableAxes has inconsistent ticks

I'm using latest v2.x (4ea9892) to build some documentation and several examples are a bit non-reproducible. It seems like this is usually triggered by the examples that use AxesGrid. I've drilled down to it being something weird with LocatableAxes, which can be seen with this example:

import sys

import matplotlib.pyplot as plt
from matplotlib.transforms import Bbox
from mpl_toolkits.axes_grid1.axes_divider import LocatableAxes
from mpl_toolkits.axes_grid1.mpl_axes import Axes

AxesClass = LocatableAxes
#AxesClass = Axes

fig = plt.figure(1)
ax = AxesClass(fig, Bbox([[0.05, 0.05], [0.95, 0.95]]))
fig.add_axes(ax)

plt.savefig(sys.argv[1] + '.png')


If you run two or three times and compare the images, the ticks in the corners will generally be slightly off, usually differing by one bit in the outermost pixel. If you uncomment the line above to use Axes instead, then there is no issue. If I understand correctly, LocatableAxes just adds the LocatableAxesBase mixin to Axes, which appears to do nothing much by default. So I don't really understand why it breaks stuff.

Answer

It's a matplotlib bug. For now just uncomment the lines for now.