I have a pandas dataframe with three columns. The first column is value z, and the other two columns are polar coordinates (r and phi, respectively, where phi is assumed degrees). r and phi are whole numbers such that they range r=[0,1,2…N] and phi=[0,1,2…360].
I would like to create a polar plot for the value, z, based on the coordinates provided. To do this, I would think a contour plot would be the solution. I first realized the contour function needs a mesh grid, so I used that instead of taking the columns from my df. Still, when I try using this code:
phi_range = np.radians(np.linspace(0, 360, 1))
r_range = np.arange(0, 10, 1)
r, theta = np.meshgrid(phi_range, r_range)
fig, ax = plt.subplots(subplot_kw=dict(projection='polar'))
ax.contourf(theta, r, z)
I get the error Input z must be 2D, not 1D
. This makes sense to me. In polar plots I have done in the past, I have usually been able to pass the meshgrid through a function to generate the value z. In this case, however, I have to use the dataset I have been given.
Is there a way to still make this type of plot?