Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Matplotlib: axis ticks number format - engineering notation

Background

Axis ticks can be converted to scientific format as suggested here.

Numbers can be converted into engineering format, one at a time as shown here

Question

How to format axis ticks in engineering notations i.e. order of magnitude is a multiple of 3.

like image 499
Neeraj Hanumante Avatar asked Dec 10 '25 12:12

Neeraj Hanumante


1 Answers

You may want to explain exactly what you mean by "engineering notation", but there is an EngFormatter, which automatically uses the SI unit prefixes (ie micro, milli, kilo, mega, etc.)

fig, ax = plt.subplots()
ax.set_ylim(0,1e6)
ticker = matplotlib.ticker.EngFormatter(unit='')
ax.yaxis.set_major_formatter(ticker)

resulting graph with engineering notation on y-axis

like image 159
Diziet Asahi Avatar answered Dec 12 '25 08:12

Diziet Asahi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!