4

我需要可视化传感器的视野。所以,我需要使用 python matplotlib 绘制一个扇区并用颜色(alpha<1)填充这个扇区。请问有什么建议吗?

4

2 回答 2

10

使用楔形艺术家

在此处输入图像描述

如下:

import matplotlib
from matplotlib.patches import Wedge
import matplotlib.pyplot as plt

fig=plt.figure()
ax=fig.add_subplot(111) 

fov = Wedge((.2,.2), 0.6, 30, 60, color="r", alpha=0.5)

ax.add_artist(fov)

plt.show()
于 2013-06-25T11:21:08.987 回答
1
import matplotlib.pyplot as plt
import matplotlib.patches as patches
fig1 = plt.figure()
ax1 = fig1.add_subplot(111, aspect='equal')
ax1.add_patch(
    patches.Wedge(
        (0, 0),         # (x,y)
        200,            # radius
        60,             # theta1 (in degrees)
        120,            # theta2
        color="g", alpha=0.2
    )
)

plt.axis([-150, 150, 0, 250])

plt.show()
于 2017-07-13T08:23:30.230 回答