如何使用 matplotlib 在极坐标图中绘制曲线 line/arc?

How to draw a curved line/arc in a polar plot with matplotlib?

我正在尝试弄清楚如何在极坐标图中的两点之间创建弧线,但我绘制的线是连接它们的直线,即使该图是极坐标。

是否需要使用其他绘图函数来代替 ax.plot

我注意到 matplotlib 中有一些补丁,这可能是我应该使用的补丁,但我不确定如何以这种方式添加它们。

如何在极坐标图上从A点和B点画一条曲线?

# Create polar plot object
with plt.style.context("seaborn-white"):
    fig = plt.figure(figsize=(5,5))
    ax = fig.add_subplot(111, projection="polar")
    # Draw 3 lines
    for degree in [90, 210, 330]:
        rad = np.deg2rad(degree)
        ax.plot([rad,rad], [0,1], color="black", linewidth=2)
    # Connect two points with a curve
    for curve in [[[90, 210], [0.5, 0.8]]]:
        curve[0] = np.deg2rad(curve[0])
        ax.plot(curve[0], curve[1])

极坐标投影意味着您不再使用 x,y 坐标系,而是使用极坐标系。尽管如此,两点之间的情节仍然是它们之间的直线。
你想要做的是像这样自己定义圆弧:

from matplotlib import pyplot as plt
from scipy.interpolate import interp1d
import numpy as np

with plt.style.context("seaborn-white"):
    fig = plt.figure(figsize=(5,5))
    ax = fig.add_subplot(111, projection="polar")
    # Draw 3 lines
    for degree in [90, 210, 330]:
        rad = np.deg2rad(degree)
        ax.plot([rad,rad], [0,1], color="black", linewidth=2)
    # Connect two points with a curve
    for curve in [[[90, 210], [0.5, 0.8]]]:
        curve[0] = np.deg2rad(curve[0])
        x = np.linspace( curve[0][0], curve[0][1], 500)
        y = interp1d( curve[0], curve[1])( x)
        ax.plot(x, y)

plt.show()