I am trying to recreate the contour plot shown below in Matplotlib, using the following code to generate the data:
theta = np.arange(math.radians(0), math.radians(361),0.01).tolist() # initialise theta values
g4 = []
for i in theta:
v = ((2**(1-1)) * (1 + (1*math.cos(i)))**1) # equation to generate the data
g4.append(v)
fig, ax = plt.subplots(subplot_kw={'projection': 'polar'})
ax.scatter(theta, g4, c=g4, cmap='viridis')
So far, I have been able to generate a scatter plot using this data which looks as follows:
However I am completely unsure of how to convert my data into the correct form to produce the required scatter plot, I have tried:
ax.contourf(theta, g4, g4)
But I get TypeError: Input z must be 2D, not 1D