2017-03-29 123 views
3

我正在尝试创建一个具有径向轴的天文极坐标图,该坐标轴从外线上的-45°开始,并在图的中心增加到90°。但我没有找到任何方法来反转PolarAxes实例的径向轴。 invert_yaxis()方法根本不起作用。此外,还有一些隐藏方法,如ax.set_rlim()没有任何文档。Matplotlib极坐标图的反径向轴

这里是我当前的代码:

fig = plt.figure() 
ax = fig.add_axes([0.1,0.1,0.8,0.8], polar=True) 
# ax.invert_yaxis() 
ax.set_theta_zero_location('N') 
ax.set_ylim(-45, 90) 
ax.set_yticks(np.arange(-45, 90, 15)) 
ax.plot(ras, decs, linestyle='', marker='.') 

和我的阴谋

+0

看到这个问题的答案:http://stackoverflow.com/questions/12075001/set-radial-axis-on-matplotlib-polar-plots – Craig

回答

1

这是一个有点“哈克”,但如果你知道的范围(这好像你做因为它对应于赤纬),你可以做类似的事情:

import matplotlib.pyplot as plt 
import numpy as np 

fig = plt.figure() 
ax = fig.add_axes([0.1,0.1,0.8,0.8], polar=True) 
# ax.invert_yaxis() 
ax.set_theta_zero_location('N') 
ax.set_rlim(90, -45, 1) 
# Note: you must set the end of arange to be slightly larger than 90 or it won't include 90 
ax.set_yticks(np.arange(-45, 91, 15)) 
ax.set_yticklabels(ax.get_yticks()[::-1]) 
ax.plot([0,10,20], 90-np.array([12,13,14]), linestyle='', marker='.') 
fig.show() 

enter image description here

+0

它看起来不错,但实际的轴仍然是相同的 - 看看价值。所以我们也需要转换它们。 –