How do I identify and display a single line in a multi-line plot?

조회 수: 3 (최근 30일)
Frankie Pereda
Frankie Pereda 2016년 5월 9일
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개)

카테고리

Help CenterFile Exchange에서 Language Fundamentals에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by