简体   繁体   中英

Fine-tuning of pcolor() polar plot

I have a 64x360 Matrix of values belonging to radial and azimuthal coordinates. I want to visualize them in two plots: a cartesian and a polar plot. I visualized the heatmap in cartesian coordinates using imshow():

import numpy as np
import matplotlib.pyplot as plt

P=np.loadtxt('Pdata.csv')
print np.shape(P)
plt.imshow(P)
plt.xlabel('radius')
plt.ylabel('theta')
plt.show()

This gives me the desired plot: 在此处输入图片说明

The same plot in polar coordinates was also pretty straigh forward using pcolor():

r=np.arange(0,np.shape(P)[1],1)
t=np.arange(0,np.shape(P)[0],1)

R,T  = np.meshgrid(r,t)

fig = plt.figure()
ax = fig.add_subplot(111, polar = True)
ax.pcolor(T,R,P)   
plt.show()

However, I am not really satisfied with the result: 在此处输入图片说明

The resolution of the plot seems to be pretty limited so that it's not possible to distinguish between angles with higher intensity and lower intensity, as it is in the cartesian plot. The whole solid angle seems to be divided into six or seven "cake wedges" only. Is there an easy and pythonic way to enhance the angular resolution?

Ok, I found out something. It works with:

t = np.radians(np.linspace(0, np.shape(P)[0],np.shape(P)[0]))
r = np.arange(0, np.shape(P)[1], 1)

Just as seen here: Polar contour plot in matplotlib - best (modern) way to do it?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM