Python matplotlib polar graph

I use the following code to build sin in the polar

from pylab import *
import matplotlib.pyplot as plt
from pylab import *
import numpy as np
theta = np.arange(0, 2*np.pi, .01)[1:] 

def f(x):
    return x

plt.polar(theta, sin(theta))
show()

and the result:

enter image description here

but I want to build its symmetry, I mean like this:

enter image description here

how can i change theta to build this? thank.

+4
source share
2 answers

Matplotblib fields allow a negative radius. So, if you need a symmetrical graph, you need to build the absolute value of sin:

polar(theta, abs(sin(theta)))

enter image description here

+4
source

Anon, you need to build the opposite value sin(theta):

plt.polar(theta, sin(theta))
plt.polar(theta, -sin(theta))

enter image description here

+2
source

Source: https://habr.com/ru/post/1665683/


All Articles