Fix issue with getting the wrong preferred values for the scale bar. by ericpre · Pull Request #23 · ppinard/matplotlib-scalebar (original) (raw)

Fixes the following issue:

import matplotlib.pyplot as plt import numpy as np from matplotlib_scalebar.scalebar import ScaleBar plt.figure() image = np.arange(25).reshape((5, 5)) plt.imshow(image) scalebar = ScaleBar(1, units='px', dimension='pixel-length') plt.gca().add_artist(scalebar)

image

While we would expect:

image

It seems that the wrong preferred value is picked up when looking up the _PREFERRED_VALUES list.