[英]how to draw a colored sector using python?
I need to visualize the field of view of a sensor. 我需要可视化传感器的视野。 So, I need to draw a sector using python matplotlib and fill this sector with a color (alpha<1).
因此,我需要使用python matplotlib绘制一个扇区,并用颜色(alpha <1)填充该扇区。 Any suggestions please ?
有什么建议吗?
Use a Wedge Artist : 使用楔子艺术家 :
As follows: 如下:
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()
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()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.