Borrar filtros
Borrar filtros

Matlab plot enhancements for value showing

1 visualización (últimos 30 días)
MattC
MattC el 5 de Mzo. de 2023
Comentada: Walter Roberson el 6 de Mzo. de 2023
Is there a way we can change what we see currently when clicking on a particular point in the plot?
When I click on a point in the graph I see X 1 and Y 0.1335 but I am interested in showing only A = 0.1335 instead and likewise if it is a B point then the same

Respuestas (1)

Walter Roberson
Walter Roberson el 5 de Mzo. de 2023
If you are using datacursormode then supply a custom update function that returns a cell array of character vectors, one cell for each output line.
Otherwise: particular kinds of plots called "charts" support a newer mechanism that allows a different method of customization; see https://www.mathworks.com/help/matlab/creating_plots/create-custom-data-tips.html
  6 comentarios
MattC
MattC el 6 de Mzo. de 2023
I tried doing that and looks like it messes up with my data point and the chart itself. I cannot see any of my datapoints, legends, and it did not show the value upon clicking the point as well
Walter Roberson
Walter Roberson el 6 de Mzo. de 2023
I tested with
h(1) = plot(rand(1,20), 'DisplayName', 'A');
hold on
h(2) = plot(rand(1,20), 'DisplayName', 'B');
hold off
row1 = dataTipTextRow('A' + " = ", 'YData');
row2 = dataTipTextRow('B' + " = ", 'YData');
h(1).DataTipTemplate.DataTipRows = row1;
h(2).DataTipTemplate.DataTipRows = row2;
legend(h);
and then I used the axis toolbare to turn on datatips for the axes. Everything looked fine, with the datatip moving to the closest point to where I clicked, and using the proper "A = " or "B = " before the value.

Iniciar sesión para comentar.

Categorías

Más información sobre Line Plots en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by