简体   繁体   中英

Format the y-axis label in the higher thousands with many zeros to scientific notation?

How can I tighten the y-axis by using scientific notation?

import numpy as np
import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(111)

x=[1,2,3,4,5,6,7,8,9,10]
y=np.array([1,1,1,2,10,2,1,1,1,1])*100000
ax.plot(x, y)

在此处输入图像描述

With plt.ticklabel_format :

import numpy as np
import matplotlib.pyplot as plt

fig = plt.figure()
ax = fig.add_subplot(111)

x=[1,2,3,4,5,6,7,8,9,10]
y=np.array([1,1,1,2,10,2,1,1,1,1])*100000
ax.plot(x, y)
plt.ticklabel_format(axis="y", style="sci", scilimits=(0,5))
plt.show()

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM