I am trying to plot a grid data in polar projection. However, I would need to set the minimal value on the Y (r) axis, but the set_rmin() seems not to be working - disregarding of the value putt in, the plot does not change.
Also, the minor issue, does anyone know how to plot the grid OVER the actual colorplot? So far I have fixed it by drawing circles around manually, but this seems to be rather inelegant.
Cheers
Attached is the plotting part of the script:
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)
You should set ax1.set_rmin(0.5)
after you set ax1.set_rscale('log')
. You may also need to set ax1.set_rmax()
to an appropriate value.
EDIT:
Looks like you need to set rscale = log
, then rmax
, then rmin
, otherwise it won't work:
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!