Adding vertical lines to subplots
12 次查看(过去 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!