Nota
Haga clic aquí para descargar el código de ejemplo completo
Selector de polígono #
Muestra cómo crear un polígono de forma programática o interactiva.
import matplotlib.pyplot as plt
from matplotlib.widgets import PolygonSelector
Para crear el polígono programáticamente
fig, ax = plt.subplots()
fig.show()
selector = PolygonSelector(ax, lambda *args: None)
# Add three vertices
selector.verts = [(0.1, 0.4), (0.5, 0.9), (0.3, 0.2)]

Para crear el polígono de forma interactiva
fig2, ax2 = plt.subplots()
fig2.show()
selector2 = PolygonSelector(ax2, lambda *args: None)
print("Click on the figure to create a polygon.")
print("Press the 'esc' key to start a new polygon.")
print("Try holding the 'shift' key to move all of the vertices.")
print("Try holding the 'ctrl' key to move a single vertex.")

Click on the figure to create a polygon.
Press the 'esc' key to start a new polygon.
Try holding the 'shift' key to move all of the vertices.
Try holding the 'ctrl' key to move a single vertex.
Referencias
En este ejemplo se muestra el uso de las siguientes funciones, métodos, clases y módulos: