我试图在极坐标投影中绘制网格数据。但是,我需要在Y(r)轴上设置最小值,但是set_rmin()似乎不起作用 - 忽略putt值,绘图不会改变。
另外,小问题,有没有人知道如何在实际颜色图上绘制网格?到目前为止,我已经通过手动绘制圆圈来修复它,但这似乎相当不优雅。
干杯
附件是剧本的绘图部分:
ax1 = plt.subplot(gs[x,y], projection="polar")
ax1.set_theta_zero_location('N')
ax1.set_theta_direction(-1)
ax1.set_rmin(0.5)
ax1.set_rscale('log')
im=ax1.pcolormesh(theta,r,dataMasked.T, vmin = 0.5, vmax = vmax_,cmap='spectral')
im.cmap.set_bad('w',1.)
ax1.set_yticks(range(0, 90, 15))
ax1.yaxis.grid(True)
答案 0 :(得分:0)
在设置ax1.set_rmin(0.5)
之后,您应该设置ax1.set_rscale('log')
。您可能还需要将ax1.set_rmax()
设置为适当的值。
修改强>
您需要设置rscale = log
,然后设置rmax
,然后设置rmin
,否则将无效:
In [1]: import matplotlib.pyplot as plt
In [2]: ax1 = plt.subplot(111, projection="polar")
In [3]: ax1.get_rmin(), ax1.get_rmax()
Out[3]: (0.0, 1.0) # Looks ok
In [4]: ax1.set_rmin(0.5)
In [5]: ax1.get_rmin(), ax1.get_rmax()
Out[5]: (0.5, 1.0) # Looks ok
In [6]: ax1.set_rscale('log')
In [7]: ax1.get_rmin(), ax1.get_rmax()
# Setting rscale=log changes both rmin and rmax
Out[7]: (9.9999999999999995e-08, 1.0000000000000001e-05)
In [8]: ax1.set_rmin(0.5)
In [9]: ax1.get_rmin(), ax1.get_rmax()
# OK, so that didn't work, because we were trying to
# set rmin to a value greater than rmax
Out[9]: (1.0000000000000001e-05, 0.5)
# Set both rmax and rmin (rmax first)
In [10]: ax1.set_rmax(1); ax1.set_rmin(0.5)
In [11]: ax1.get_rmin(), ax1.get_rmax()
Out[11]: (0.5, 1.0) # Success!