Partition line in a subplot
조회 수: 1 (최근 30일)
이전 댓글 표시
How can I add partition line to a subplot in matlab(Hand sketch is attached for reference).
clc;close all; clear all;
x=[1 2 5 4 6 7];
y=[5 6 2 5 8 4];
subplot(4,3,1);plot(x,y);
subplot(4,3,2);plot(x,y);
subplot(4,3,3);plot(x,y);
subplot(4,3,4);plot(x,y);
subplot(4,3,5);plot(x,y);
subplot(4,3,6);plot(x,y);
subplot(4,3,7);plot(x,y);
subplot(4,3,8);plot(x,y);
subplot(4,3,9);plot(x,y);
subplot(4,3,10);plot(x,y);
subplot(4,3,11);plot(x,y);
subplot(4,3,12);plot(x,y);
댓글 수: 0
채택된 답변
Dyuman Joshi
2023년 6월 5일
You can do this by turning clipping off and manually drawing lines -
clc;close all; clear all;
x=[1 2 5 4 6 7];
y=[5 6 2 5 8 4];
subplot(4,3,1);plot(x,y);
%1st vertical line
%Clipping off
set(gca,'Clipping','Off')
xl = xlim;
yl = ylim;
%Make lines according to the x and y limits of the plot
%change x and y values as required
%Note that you will have to manually adjust these for different data
h = line(max(xl)+[1 1],[-25 max(ylim)+2.5]);
%Set line properties as required
set(h,'LineWidth',1,'LineStyle','--','Color','r')
%Adjust xlimits back to original
xlim(xl)
subplot(4,3,2);plot(x,y);
%2nd vertical line
%Clipping off
set(gca,'Clipping','Off')
xl = xlim;
yl = ylim;
%Make lines according to the x and y limits of the plot
%change x and y values as required
%Note that you will have to manually adjust these for different data
h = line(max(xl)+[1 1],[-25 max(ylim)+2.5]);
%Set line properties as required
set(h,'LineWidth',1,'LineStyle','--','Color','r')
%Adjust xlimits back to original
xlim(xl)
subplot(4,3,3);plot(x,y);
subplot(4,3,4);plot(x,y);
subplot(4,3,5);plot(x,y);
subplot(4,3,6);plot(x,y);
subplot(4,3,7);plot(x,y);
subplot(4,3,8);plot(x,y);
%1st vertical line
%Clipping off
set(gca,'Clipping','Off')
xl = xlim;
yl = ylim;
%Make lines according to the x and y limits of the plot
%change x and y values as required
%Note that you will have to manually adjust these for different data
h = line([-10 17.5], max(yl)+[1 1]);
%Set line properties as required
set(h,'LineWidth',1,'LineStyle','--','Color','r')
%Adjust ylimits back to original
ylim(yl)
subplot(4,3,9);plot(x,y);
subplot(4,3,10);plot(x,y);
subplot(4,3,11);plot(x,y);
subplot(4,3,12);plot(x,y);
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Subplots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!