设置yticks位置Matplotlib [英] Setting yticks Location Matplotlib

查看:561
本文介绍了设置yticks位置Matplotlib的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图创建一个y轴完全与此相同的情节:


我现在处在这种情况下,一切正常,直到这一点:





当我尝试以下行时:

  ax.set_yticks(范围(20,67,10))
ax.set_yticklabels(['20','30','40','50','60'])

我的图形正在变成这样:



我无法理解如何正确设置yticks的位置。

解决方案

如果您需要坐标轴上的数字,请确保您绘制的是数字,而不是字符串。然后,轴标签会根据需要自动调整,或者您可以使用 set_yticks set_yticklabels p>

I'm trying to create a plot which has y axis exactly same with this :

And I'm in this situation and everything is ok until this point:

When i try this lines:

ax.set_yticks(range(20,67,10))
ax.set_yticklabels(['20','30','40','50','60'])

My graph is becoming this:

I couldn't understand how to set locations' of yticks properly.

解决方案

If you want numbers on the axes, make sure you plot numbers, not strings. The axis labels would then adjust automatically as desired, or you may use set_yticks and set_yticklabels as in the question.

这篇关于设置yticks位置Matplotlib的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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