加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

python – 在matplotlib中设置errorbars的显示范围suplot

发布时间:2020-12-20 11:21:56 所属栏目:Python 来源:网络整理
导读:我正在尝试使用matplot lib绘制我的数据.我有3个separetes数据集我想在3个子图中绘制(我使用 this是我的指导): plt.figure()fig,axs = plt.subplots(nrows=3,ncols = 1,sharex=False)ax1 = axs[0]ax1.errorbar(X,Y,Err,fmt='o')ax1.set_xscale('log')ax1.se
我正在尝试使用matplot lib绘制我的数据.我有3个separetes数据集我想在3个子图中绘制(我使用 this是我的指导):

plt.figure()

fig,axs = plt.subplots(nrows=3,ncols = 1,sharex=False)
ax1 = axs[0]
ax1.errorbar(X,Y,Err,fmt='o')
ax1.set_xscale('log')
ax1.set_yscale('log')
ax1.set_title('epsilon=1.5,kappa = 2')
plt.show()

但是我得到的x范围从1(或0,我不确定)到100,我想减少它.我试过this,添加使用:

ax1.xlim(0.5,13.5)

但是我收到一个错误:

AttributeError: ‘AxesSubplot’ object has no attribute ‘xlim’

我怎样才能改变范围呢?

解决方法

您可能想要使用Axes.axis(* v,** kwargs):

ax1.axis(xmin=0.5,xmax=13.5)

从文档:

Set/Get the axis properties

If len(*v)==0,you can pass in xmin,xmax,ymin,ymax as kwargs selectively to alter just those limits without changing the others.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读