[英]Move radial tick labels on a polar plot in matplotlib
来自matplotlib的例子 :
import numpy as np
import seaborn as sbs
import matplotlib.pyplot as plt
r = np.arange(0, 3.0, 0.01)
theta = 2 * np.pi * r
ax = plt.subplot(111, polar=True)
ax.plot(theta, r, color='r', linewidth=3)
ax.set_rmax(2.0)
ax.grid(True)
ax.set_title("A line plot on a polar axis", va='bottom')
plt.show()
如何将径向刻度标签(0.5,1.0,1.5,2.0)移动到不同的角度,比如120度?
对于1.4或更高版本,您可以使用“set_rlabel_position”。 例如,将径向刻度线放置在135度的长线上:
ax.set_rlabel_position(135)
相关文档存在于此处 ,有点隐藏在“投影”下。
添加上面的行产生(我没有seaborn所以这有默认的matplotlib格式):
在1.4之前, ax.set_rgrids
可以采用角度参数。
我尝试使用@ alkamid的回答编辑运行示例代码,但最终以错误结束
AttributeError: 'PolarAxesSubplot' object has no attribute 'set_rlabel_position'
我的matplotlib版本是1.3.1。 但是我发现这个答案python matplolib极坐标图x轴标签位置用以下代码行:
ax.set_rgrids([5,10], angle=22)
这对我有用,并产生了想要的输出。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.