Adding vertical lines to subplots
조회 수: 13 (최근 30일)
이전 댓글 표시
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
답변 (1개)
Joseph Cheng
2014년 4월 1일
편집: Joseph Cheng
2014년 4월 1일
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');
참고 항목
카테고리
Help Center 및 File Exchange에서 Subplots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!