Python Matplotlib 极坐标图绘制

4
我正在使用以下代码创建正弦波的极坐标图。
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()

产生的结果为:

enter image description here

但我想对其进行对称绘制,如下所示:

enter image description here

我该如何得到我想要的结果?


为什么要定义f()函数? - Lucas
2个回答

4

Matplotlib极坐标图支持负半径,因此,如果要绘制对称的图形,则需要绘制正弦值的绝对值:

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

enter image description here


2
匿名用户,您需要绘制sin(theta)的相反数:
plt.polar(theta, sin(theta))
plt.polar(theta, -sin(theta))

enter image description here


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接