Skip to content
Advertisement

Can I turn off scientific notation in matplotlib bar chart?

I have a bar chart that looks like how I want it to look, except for the scientific notation on the y-axes.

Some other solutions included using

JavaScript

which didn’t work. Also, I tried checking whether this was an offset-problem, but it should have shown a ‘+’ sign, which it doesn’t in this case.

Whenever I use:

JavaScript

I get an error message saying:

JavaScript

I’ve looked into this ScalarFormatter, but I couldn’t get any wiser as to why it doesn;t work. I’ve tried to explicitly include it in the code, but it doesn’t work.

The code I use is:

JavaScript

The chart currently looks like this:

enter image description here

Advertisement

Answer

You can use FuncFormatter of the matplotlib.ticker to update the ticks as you wish on your current plot. In my example below, the ticks are updated using a custom scientific_formatter, that I defined to update the ticks in scientific notation with 2 precision digits – %2E.

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement