Search code examples
pythonpython-3.xmatplotlibplotpolar-coordinates

Polar plot in Python looks quite strange


with a long piece of Python code I have obtained two arrays: phi (which contains 0,1,2,...,360) and F.

If I plot F vs phi in a cartesian plot, with simply these two instructions:

plt.plot(phi,F)
plt.show()

I get the following graph.

enter image description here

However, if I try to plot it in a polar graph with the following piece of code:

plt.polar(phi,F)
plt.show()

I get the following graph.

enter image description here

The last one is not what I was expecting. I'm expecting something like a noisy circumference, since the cartesian plot of F vs phi shows a noisy behaviour with a mean value at -0.8.

I was expecting to get something similar (with different values since it refers to other variables) to this graph: enter image description here

UPDATE1: As suggested by @luuk, I've converted phi from degrees to radians. Now I get this result.

enter image description here

UPDATE2: After changing the rlims (set from -2 to 0.1), the picture looks like this

enter image description here

It's still strange since there is a filled circle inside the graph. Do you know how can I remove it (if it's simply due to too dense lines)?

UPDATE 3:

If I plot it with points ('.i' in plot) I get a reasonable plot. But, if possible, I'd prefer to get a plot with lines.

enter image description here


Solution

  • As you can see from the Polar Demo, plt.polar() expects the theta argument to be in radians (with domain [0, 2π]), not in degrees. Convert phi to radians by multiplying by np.pi/180.