Adding vertical lines to subplots
13 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I'd like to add vertical lines to two subplots to indicate censored time points along different time series. However, when I run the script, they only show up on the second subplot. How would I apply vertical lines to both? Thanks alot!
fulldata_1=load('timeseries_1.1D');
censordata_1=load('censor_1.txt');
fulldata_2=load('timeseries_2.1D');
censordata_2=load('censor_2.txt');
fig=figure;
h1 = subplot(2,1,1);
h2 = subplot(2,1,2);
C1=censordata_1;
C2=censordata_2;
plot(h1,fulldata_1);
line([C1 C1],get(h1,'YLim'),'Color',[1 0 0]);
title(h1,'DVARS Censor');
plot(h2,fulldata_RMSD);
line([C2 2],get(h2,'YLim'),'Color',[1 0 0]);
title(h2,'RMSD Censor');
0 Kommentare
Antworten (1)
Joseph Cheng
am 1 Apr. 2014
Bearbeitet: Joseph Cheng
am 1 Apr. 2014
you'll have to set the active axes before you do each line. Subplot h2 was the only one with the lines because it was the last item created and thus set as the current active axes. using axes() it will set the axes you wish to work with.
h1 = subplot(2,1,1);
h2 = subplot(2,1,2);
plot(h1,rand(10));
axes(h1)
line([2 2],get(h1,'YLim'),'Color',[1 0 0]);
title(h1,'DVARS Censor');
plot(h2,rand(5));
axes(h2)
line([4 4],get(h2,'YLim'),'Color',[1 0 0]);
title(h2,'RMSD Censor');
Siehe auch
Kategorien
Mehr zu Subplots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!