3

First I would like to apologize as I know I am not asking this question correctly (which is why I cant find what is likely a simple answer).

I have a graphgraph

As you can see above the y axis it says 1e11 meaning that the units are in 100 Billions. I would like to change the graph to read 100 Billion instead of 1e11.

I am not sure what such a notation is called.

To be clear I am not asking to change the whole y axis to number values like other questions I only want to change the top 1e11 to be more readable to those who are less mathematical.

ax.get_yaxis().get_major_formatter().set_scientific(False)

results in enter image description here an undesired result

Kevin Riordan
  • 149
  • 1
  • 8

1 Answers1

4
import numpy as np
from matplotlib.ticker import FuncFormatter

def billions(x, pos):
    return '$%1.1fB' % (x*1e-9)

formatter = FuncFormatter(billions)

ax.yaxis.set_major_formatter(formatter)

located from https://matplotlib.org/examples/pylab_examples/custom_ticker1.html

produces enter image description here

Kevin Riordan
  • 149
  • 1
  • 8