如何在固定位置、matplotlib 上设置刻度 [英] How to set ticks on Fixed Position , matplotlib
本文介绍了如何在固定位置、matplotlib 上设置刻度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
谁能帮我使用 matplotlib 在固定位置设置刻度?我已经尝试使用 FixedPosition 作为本教程描述的:
Can anyone help me set the ticks on a fixed position using matplotlib? I've tried using FixedPosition as this tutorial describes:
ax = pl.gca()
ax.xaxis.set_major_locator(eval(locator))
http://scipy-lectures.github.io/intro/matplotlib/matplotlib.html#figures-subplots-axes-and-ticks
但是当我尝试运行时,它告诉我 set_major_locator 方法不存在.
But when I try to run, it tells me that set_major_locator method does not exist.
一个简单的例子会非常有用.
A simple example would be very useful.
谢谢.
推荐答案
只需使用 ax.set_xticks(positions)
或 ax.set_yticks(positions)
.
例如:
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.set_xticks([0.15, 0.68, 0.97])
ax.set_yticks([0.2, 0.55, 0.76])
plt.show()
这篇关于如何在固定位置、matplotlib 上设置刻度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文