Adding scientific notation to y-axis changes height of bars in matplotlib bar plot

Viewed 106

I want to make a bar plot with scientific notation on the y-axis.

However, when I use plt.ticklabel_format(axis="y", style="scientific", scilimits=(0,0), useOffset = False, useMathText=True), the height of my bar changes and thus are not true to the input parameters.

I really don't know why this is happening. Please see the two attached plots and code.

fig = plt.figure()
# with and without below line
plt.ticklabel_format(
    axis="y", 
    style="scientific", 
    scilimits=(0,0), 
    useOffset = False, 
    useMathText=True,
)
plt.bar(x=x, height = height)
plt.xlabel('Load case no.')
plt.ylabel('Damage [-]')

plt.grid(axis="y",linestyle='--')
plt.draw()
Without scientific notation With scientific notation
Without scientific notation (defualt) With scientific notation
0 Answers
Related