gname for labelling lines in a plot
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Felix
am 23 Sep. 2015
Kommentiert: Felix
am 25 Sep. 2015
I want to use gname() to identify the lines of a plot with multiple lines.
I am trying to do it like this:
timeseries = rand(100,3); plot(timeseries); gname({'a','b','c'});
which doesn't work.
If I invert the matrix I can use gname() for labelling, however the plot is obscured:
timeseries = rand(100,3); plot(timeseries'); gname({'a','b','c'})
Would be nice if that could work somehow, I would like to plot hundreds of timeseries in one plot, but the colour labelling doesnt really help to identify them.
0 Kommentare
Akzeptierte Antwort
Kelly Kearney
am 23 Sep. 2015
Maybe setting the ButtonDownFcn of each line to display the name somewhere would work? In this example, I change the axis title:
hax = axes;
changetext = @(str) title(hax, str);
hln = plot(1:3, rand(3,100));
for ii = 1:100
hln(ii).ButtonDownFcn = @(~,~) changetext(num2str(ii));
end
3 Kommentare
Kelly Kearney
am 24 Sep. 2015
For that version, replace
hln(ii).ButtonDownFcn = @(~,~) changetext(num2str(ii));
with
set(hln(ii), 'ButtonDownFcn', @(~,~) changetext(num2str(ii)));
Weitere Antworten (1)
Siehe auch
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!