I am on Python 3.9 and matplotlib 3.7 working in a jupyter-notebook on macos.
I have a range of x values from 0 to 500 000. When turning on scientific notation, it uses the 10^5 as the order of magnitude. I want it to display as multiples of 10^3
Here's some sample code:
import numpy as np
import matplotlib.pyplot as plt
x = np.arange(0, 5e5, 10e3)
y = np.random.random_sample(len(x))
mm = 1 / 25.4
f, ax = plt.subplots(figsize=(210 * mm, 148 * mm), dpi=600)
ax.plot(x, y)
ax.ticklabel_format(axis='x', style='sci', scilimits=(0,0),useMathText=True, useOffset=False)
Which produces this figure: x ticks as multiples of 10^5
I would like 5 x 10^5 to be displayed as 500 x 10^3, e.g.
I tried to create a mpl.ticker.ScalarFormatter object with the arguments inside the ticklabel_formatter function, but when feeding it the object, I get a positional error because it expects 2 arguments.
I have attempted to set the powerlimits attribute to 3 as well as the orderOfMagnitude attribute to 3, but the ScalarFunction rejects those keyword arguments.
I looked at this post here but the xaxis.set_major_formatter does not accept my formatter object.