如何更改pyplot轴上的增量量 [英] How to change the amount of increments in pyplot axis

查看:41
本文介绍了如何更改pyplot轴上的增量量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能是一个很简单的问题,但是..
使用 matplotlib.pyplot 绘制图形时,我的 Y 轴从 -0.04 到 0.03,这很好,但有 8 个标签用于增量(例如 0.03、0.02、0.01 等).我可能还需要16个左右.

Hi probably quite a simple question but..
When plotting a graph using matplotlib.pyplot my Y axis goes from -0.04 to 0.03 which is fine but there are 8 labels for increments (eg 0.03,0.02,0.01 etc.). I need more maybe 16 or so.

感谢您的帮助

推荐答案

使用 set_yticks()更改刻度位置.例如:

Use set_yticks() to change the tick locations. For example:

import scipy, pylab
fig = pylab.figure()
ax = fig.add_subplot(1,1,1)
ax.plot(scipy.randn(8))
ax.set_yticks(scipy.arange(-1.5,1.5,0.25))
fig.show()

pylab.yticks() 是另一种选择.
(来源:stevetjoa.com)

pylab.yticks() is another option.
(source: stevetjoa.com)

这篇关于如何更改pyplot轴上的增量量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆