对数刻度

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())

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值