import matplotlib.pyplot as plt
import numpy as np
from pylab import *
fig,axes=plt.subplots(1,3,figsize=(12,8))
x=linspace(0,5,10)
rcParams['xtick.major.pad'] =10 #设置x轴刻度线与刻度(数字)的距离
rcParams['ytick.major.pad'] =10
axes[0].plot(x,x**2,x,exp(x))
axes[0].set_title('Normal scale')
axes[1].plot(x,x**2,x,exp(x))
axes[1].set_yscale('log')
axes[1].set_xlabel('x')
axes[1].xaxis.labelpad=5 #设置轴标签与轴刻度的距离
axes[1].set_title('Logarithmic scale (y)')
axes[2].plot(x,x**2,x,exp(x))
axes[2].set_yticks([0,50,100,150])
axes[2].set_title('Scientific notation')
from matplotlib import ticker
#刻度容器
#y轴用科学计数法表示
formatter = ticker.ScalarFormatter(useMathText=True)
formatter.set_scientific(True)
formatter.set_powerlimits((-1,1))
axes[2].yaxis.set_major_formatter(formatter)
plt.savefig('E:\python\慕课网 python\.idea\photo\对数刻度.png',dpi=400,bbox_inches='tight')
plt.show()
print(matplotlib.rc_params())
对数刻度
最新推荐文章于 2022-08-16 23:30:57 发布