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). 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()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With