matplotlib/mpl-probscale

Probplot tick and ticklabel formatting under py2.7

austinorr opened this issue · 1 comments

probplot ticks and ticklabels render incorrectly for plottype = 'prob' under py2.7.11

code as follows:

import warnings
warnings.simplefilter('ignore')

import numpy
from matplotlib import pyplot
import seaborn

import probscale
clear_bkgd = {'axes.facecolor':'none', 'figure.facecolor':'none'}
seaborn.set(style='ticks', context='notebook', rc=clear_bkgd)
%matplotlib inline
In [2]:
numpy.random.seed(0)
sample = numpy.random.normal(loc=4, scale=2, size=37)
In [3]:
fig, (ax1, ax2, ax3) = pyplot.subplots(nrows=3, figsize=(5.5, 7))

probscale.probplot(sample, ax=ax1, plottype='pp', xlabel='Percentiles')
probscale.probplot(sample, ax=ax2, plottype='qq', xlabel='Quantiles')
probscale.probplot(sample, ax=ax3, plottype='prob', xlabel='Probabilities')

ax2.set_xlim(left=-2.5, right=2.5)
ax3.set_xlim(left=0.5, right=99.5)
fig.tight_layout()
seaborn.despine(fig=fig)

Out [3]:

image

Is it possible to manually format tick labels, or is their formatting handled completely internally? I was not able to retrieve them and apply string formatting to them manually.

I'm not inclined to spend any effort supporting legacy python, but retrieving the labels and applying string formatting is not how matplotlib tick labels are formatted. Instead you pass a Formatter class to e.g., ax.xaxis.set_major_formatter. String formatting also won't help rendering issues

The crux of the probscale formatter is here:
https://github.com/phobson/mpl-probscale/blob/master/probscale/formatters.py#L75

And here's an example of using matplotlib's FuncFormatter function to create a custom formatter class:
http://matplotlib.org/examples/pylab_examples/custom_ticker1.html