Partition line in a subplot

1 回表示 (過去 30 日間)
Reji G
Reji G 2023 年 6 月 5 日
コメント済み: Reji G 2023 年 6 月 5 日
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);

採用された回答

Dyuman Joshi
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);
  1 件のコメント
Reji G
Reji G 2023 年 6 月 5 日
Thank you. Charm

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSubplots についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by