Adding additional information on plot tooltip

Hi
I have a plot , when i hover over the plot line, it displays the value. At the same time i would like to also display the temperture, which is also part of the dataset but not displayed on the plot.
How do i edit the tooltip, so that additional information can be displayed on the tooltip ?

Respuestas (1)

Simon Chan
Simon Chan el 21 de Jun. de 2022

2 votos

Use function dataTipTextRow

3 comentarios

Dharmesh Joshi
Dharmesh Joshi el 21 de Jun. de 2022
Thanks
This my code now
plot(t,ug,ref_data_timestamp,ref_data_sensordata)
title('N02 Sensor Per Minute data')
xlabel('Date Time')
ylabel('N02 ug')
dataTipTextRow("Temperture",iot_temperture);
legend("Sensor ug", "Reference data")
When i click on the data trend on plot it does not still show the extra information
Simon Chan
Simon Chan el 21 de Jun. de 2022
You need to attach it to the DataTipTemplate property. Check DataTipTemplate as well.
Dharmesh Joshi
Dharmesh Joshi el 21 de Jun. de 2022
Hi
Ok i can get it working if my plot has only one data set e.g.
s=plot(t,ug)
But i gett the following error message, when a plot has multiple plots
s=plot(t,ug,ref_data_timestamp,ref_data_sensordata)
Intermediate dot '.' indexing produced a comma-separated list with 2 values, but it must produce a single value when followed by subsequent indexing
operations.
Error in n02 (line 141)
s.DataTipTemplate.DataTipRows(end+1) = row;

Iniciar sesión para comentar.

Categorías

Más información sobre MATLAB en Centro de ayuda y File Exchange.

Productos

Etiquetas

Preguntada:

el 21 de Jun. de 2022

Comentada:

el 21 de Jun. de 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by