I want to have ticks on the y-axis formatted the following way:
- numbers < 1M should be written out, with spaces as thousands separator (e.g.
20 000) - numbers > 1M should be in scientific notation, just as the Scalar formatter does (
2.0withx10^6above the axis).
Now, I can achieve both of these functionalities seperataly.
matplotlib.ticker.FuncFormatter(lambda x, p: format(x, ',').replace(',', ' '))
replaces thousands separator with space.
formatter = matplotlib.ticker.ScalarFormatter()
formatter.set_powerlimits((-4, 6))
gives scientific notation for 1M+.
I guess I have to set a ScalarFormatter and slightly change one of its functions, or I have to write above the y-axis with the FuncFormatter. However, I could not find how to do that.
EDIT
I slightly came closer to my goal. By using format(x, ',.6g').replace(',', ' ') I at least have the desired number formats.
Nevertheless, I'd prefer to have the exponential notation above the axis, and for all of my ticks, if the largest grows too large...
