简体   繁体   中英

python matplotlib polar plot

I am using the following code to create a polar plot of the sinus.

import numpy as np
import matplotlib.pyplot as plt


theta = np.arange(0, 2*np.pi, .01)[1:]
plt.polar(theta, sin(theta))
plt.show()

which produces:

在此输入图像描述

but I want to plot it symmetrically, like this:

在此输入图像描述

How can I get the result I want?

The matplotlib polar allows for negative radius. So, if you want the symmetric plot you need to plot the absolute value of sin:

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

在此输入图像描述

Anon, you need to plot the opposite of sin(theta) :

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

在此输入图像描述

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