diff --git a/tests/data_sample/generate_cities_with_matplotlib.py b/tests/data_sample/generate_cities_with_matplotlib.py new file mode 100644 index 0000000..b711ccf --- /dev/null +++ b/tests/data_sample/generate_cities_with_matplotlib.py @@ -0,0 +1,33 @@ +import matplotlib.pyplot as plt + +# Liste pour stocker les coordonnées des points cliqués +points = [] + +def onclick(event): + global points + # Ajouter le point cliqué à la liste + points.append([int(event.xdata), int(event.ydata)]) + + # Afficher le point sur le graphique + plt.plot(event.xdata, event.ydata, 'ro') + + plt.draw() # Redessiner le graphique + +# Créer un graphique vierge de 1000 par 1000 +fig, ax = plt.subplots(figsize=(10,10)) +plt.xlim(0, 1000) +plt.ylim(0, 1000) + +# Connecter le gestionnaire d'événements au graphique +cid = fig.canvas.mpl_connect('button_press_event', onclick) + +plt.show() + +# Afficher les points cliqués +for point in points: + print(f"Ville à la position {point}") + +# Si vous voulez avoir les positions dans une liste, vous pouvez le faire comme suit +print(points) + +input() \ No newline at end of file