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