Forum >> Programmazione Python >> Calcolo scientifico >> Valori sui markers in matplotlib

Pagina: 1

Buonasera a voi amici pythoniani.



In questi giorni sto plottando delle funzioni su matplotlib (che non avevo mai utilizzato prima d'ora, devo dire che ne sto apprezzando parecchio le potenzialità).

Sto cercando di rendere i grafici il più gradevoli e completi possibili.




Il mio quesito è il seguente, non sono riuscito a trovar nulla neanche nelle guide online;




vorrei posizionare dei marker in dei punti notevoli ben precisi sulla mia curva e associare ad ogni marker il valore che la curva assume in quei punti.

Come si potrebbe fare?



<< Somewhere, something incredible is waiting to be known >> [Carl Sagan]
Se volessimo trovare un difetto a matplotlib potremmo dire che è "troppa", ci si perde nella abbondanza di funzioni che presenta e nelle correlazioni relative.

Credo che il metodo più probabilmente adatto a ciò che chiedi sia "matplotlib.pyplot.annotate", ma ne esistono altri, anche specializzati per tipi di grafico ... alcuni esempi d'uso di annotate da una discussione su stackoverflow

Fatti non foste a viver come bruti...
Esiste anche la libreria plotly che con il passaggio del cursore sulla linea identifica il valore.

è possibile anche segnare valori sul grafico,

ti consigli di guardare questa pagina




https://plotly.com/python/line-charts/






Se volessimo trovare un difetto a matplotlib potremmo dire che è "troppa", ci si perde nella abbondanza di funzioni che presenta e nelle correlazioni relative.

Credo che il metodo più probabilmente adatto a ciò che chiedi sia "matplotlib.pyplot.annotate", ma ne esistono altri, anche specializzati per tipi di grafico ... alcuni esempi d'uso di annotate da una discussione su stackoverflow


grazieeee

studio tutto

perdonate la risposta tardiva ma non ho ricevuto le notifiche
<< Somewhere, something incredible is waiting to be known >> [Carl Sagan]
Esiste anche la libreria plotly che con il passaggio del cursore sulla linea identifica il valore.

è possibile anche segnare valori sul grafico,

ti consigli di guardare questa pagina




https://plotly.com/python/line-charts/




grazie mille gabbo!


<< Somewhere, something incredible is waiting to be known >> [Carl Sagan]
Messaggio nascosto da :
spam
​Thank you for this interesting information!
Good evening! It's great that you're enjoying using Matplotlib. To add markers at specific points on your curve and display the corresponding values, you can use the plt.scatter()function to plot the markers at the desired points. Then, to annotate those points with their values, you can use plt.annotate(). Here's an example:

import matplotlib.pyplot as plt
import numpy as np

# Sample data
x = np.linspace(0, 10, 100)
y = np.sin(x)

# Plotting the curve
plt.plot(x, y)

# Mark specific points (e.g., at x=2, x=5, and x=8)
markers_x = [2, 5, 8]
markers_y = np.sin(np.array(markers_x))

# Add markers
plt.scatter(markers_x, markers_y, color='red')

# Annotate the points
for (i, j) in zip(markers_x, markers_y):
plt.annotate(f'({i}, {j:.2f})', (i, j), textcoords="offset points", xytext=(0,5), ha='center')

plt.show()

This will plot your curve with red markers at the specified points and display the corresponding values ​​as annotations.














Pagina: 1



Esegui il login per scrivere una risposta.