我试图使用带有极坐标投影的matplotlib绘制一些点。我的印象是轴应该自动缩放以适应数据,但这似乎并不一致。
在此示例中,行为似乎不一致:
import matplotlib.pyplot as plt
def plot_polar(coords_rads):
fig = plt.figure()
#ax = fig.add_axes([0, 0, 1.2, 1.2], polar=True)
ax = fig.add_subplot(111, projection='polar')
magnitudes, angles = [list(i) for i in zip(*coords_rads)]
print angles, magnitudes
plt.scatter(angles, magnitudes)
coords_rads = [(10, 0.0), (200, 1.5707963267948966), (30, -1.5707963267948966), (100, 5.497787143782138)]
plot_polar(coords_rads) # works (radius is scaled to just over 200):
coords_rads = [(3.391, 2.061670178918302), (169.116, 0.0), (106.869, 1.0799224746714915)]
plot_polar(coords_rads) # doesn't work (radius is scaled to 100)
输出:
Plot 1 - 按预期工作(半径缩放到200以上):
图2 - 未按预期工作(半径缩放为100):
编辑:
这是一个IPython笔记本,展示了这个问题:http://nbviewer.ipython.org/gist/gabrielgrant/b6bd4ad38355a06126f5