本文介绍了如何在固定位置、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))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 上设置刻度
发布评论