3

I would like to use the nice circle that the polar projection gives, but I have cartesian data. The best I can do now is the following, but it has a notch thing.

fig, ax = plt.subplots(subplot_kw={'projection': 'polar'})

xs, ys = np.meshgrid(np.linspace(-1,1,50),np.linspace(-1,1,50),)
parab = xs**2+ys**2

rs = np.sqrt(xs**2+ys**2)
ths = np.arctan2(ys, xs)

ax.pcolormesh(ths, rs, parab, shading='nearest')

Best try

Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158
Ruiko20
  • 31
  • 2

1 Answers1

0

The parameter shading='nearest' looks like unsupported in polar projection. I manualy center the color C[i,j] on (ths[i,j], rs[i,j]) by using an other meshgrid xs_ ys_

fig, ax = plt.subplots(subplot_kw={'projection': 'polar'})

n = 50

xs, ys = np.meshgrid(np.linspace(-1,1,n),np.linspace(-1,1,n))
dx, dy = 0.5*np.ptp(xs)/(n-1), 0.5*np.ptp(ys)/(n-1)
xs_,ys_ = np.meshgrid(np.linspace(-1-dx,1+dx,n+1),np.linspace(-1-dx,1+dx,n+1))

parab = (xs_+dx)**2+(ys_+dx)**2

rs = np.sqrt(xs**2+ys**2)
ths = np.arctan2(ys, xs)

rs_ = np.sqrt(xs_**2+ys_**2)
ths_ = np.arctan2(ys_, xs_)

ax.pcolormesh(ths_, rs_, parab)

plt.show()

output :

output