How do I identify and display a single line in a multi-line plot?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I'm trying to pick out a single line in a multi-line plot. I can highlight a line and its corresponding legend item, but I'd also like to display the name of the line on the plot when the line is clicked. I've tried tooltips and the data cursor so far. Below is a simple test case:
% code
y = plot(1:0.5:3, rand(5,5));
n = length(1:0.5:3);
a = zeros(n,1);
for i = 1:n
set(y(i), 'ButtonDownFcn', {@LineSelected, y});
a(i,1) = i;
end
a = num2str(a);
legend(a)
% code
function LineSelected(ObjectH, EventData, h)
set(ObjectH, 'LineWidth', 2.5);
set(h(h ~= ObjectH), 'LineWidth', 0.5);
end
0 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Language Fundamentals dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!