Bug summary
I use a custom tick formatter in my plot. It worked great with an older version of matplotlib but I just upgraded to 2.0 and I see overlapping tickmark labels (the default labels are still there):
Code for reproduction
import numpy as np import matplotlib import matplotlib.pyplot as plt class MyLogFormatter(matplotlib.ticker.LogFormatter): def __call__(self, x, pos=None): e = np.floor(np.log10(x)) m = x/(10**e) if x < 0.01: return '%de%d' % (round(m), e) elif x < 1: return '%.2f' % x elif x < 10: return '%.1f' % x elif x < 1000: return '%.0f' % x else: return '%de%d' % (round(m), e) @staticmethod def ticks(xmin, xmax): ndecades = np.ceil(np.log10(xmax/xmin)) if ndecades > 6: mantissas = [1] elif ndecades > 3: mantissas = [1,3] else: mantissas = [1,2,5] roundnumbers = (10**np.arange(np.floor(np.log10(xmin)), np.ceil(np.log10(xmax)))*np.atleast_2d(mantissas).T).T.flatten() return np.hstack((xmin, [x for x in roundnumbers if xmin*1.25 < x < 0.8*xmax], xmax)) data = 0 for k in xrange(4): data += np.random.randint(6, size=100000) count,edges = np.histogram(data,10) x = 100 * (1.1 ** edges) fig = plt.figure(figsize=(8,6)) ax = fig.add_subplot(1,1,1,xscale='log') ax.bar(x[:-1], count, width=x[1:] - x[:-1], color='red',edgecolor='black',align='edge') xmin = min(x) xmax = max(x) LF = MyLogFormatter(labelOnlyBase=False) ax.set_xticks(LF.ticks(xmin, xmax)) ax.xaxis.set_major_formatter(LF)
Actual outcome
Expected outcome
previous version was Matplotlib 1.5.1 (can't post right now, I will have to downgrade my anaconda version)
Matplotlib version
Oh, never mind, adding this line suppresses the minor tick labels:
ax.xaxis.set_minor_formatter(matplotlib.ticker.NullFormatter())
Incidentally, what changed around minor tick labels?
See http://matplotlib.org/users/dflt_style_changes.html#logformatter-labeling-of-minor-ticks for documentation of the changes to minor ticks.
We made it better by default, but seem to have broken a bunch of people who were doing custom things.
duplicate of #8386
Activity
jason-s commented on Mar 29, 2017
Oh, never mind, adding this line suppresses the minor tick labels:
ax.xaxis.set_minor_formatter(matplotlib.ticker.NullFormatter())
Incidentally, what changed around minor tick labels?
tacaswell commented on Mar 30, 2017
See http://matplotlib.org/users/dflt_style_changes.html#logformatter-labeling-of-minor-ticks for documentation of the changes to minor ticks.
We made it better by default, but seem to have broken a bunch of people who were doing custom things.
phobson commented on Mar 30, 2017
duplicate of #8386