我如何绘制一些数据,删除由这些数据创建的轴,并用不同比例的轴替换它们?在
假设我有这样的东西:
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111)
plt.xlim([0,5])
plt.ylim([0,5])
plt.plot([0,1,2,3,4,5])
plt.show()
这将在5x5绘图中绘制一条线,两个轴的范围为0到5。我想删除0到5轴,并说用-25到25轴替换它。这只会改变坐标轴,但我不想移动任何数据,也就是说,它看起来与原始绘图相同,只是轴不同而已。我意识到这可以简单地通过移动数据来实现,但我不想更改数据。在
您可以使用
plt.xticks
来查找标签的位置,然后将标签设置为位置值的5倍。基础数据没有改变,只有标签。在收益率
或者,您可以更改ticker formatter:
^{pr2}$相关问题 更多 >
编程相关推荐