简体   繁体   English

python matplotlib极地情节

[英]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. matplotlib极性允许负半径。 So, if you want the symmetric plot you need to plot the absolute value of sin: 所以,如果你想要对称图,你需要绘制sin的绝对值:

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

在此输入图像描述

Anon, you need to plot the opposite of sin(theta) : 不,你需要绘制sin(theta)的反面:

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

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM