How can I plot my figures like attached plots?

2 次查看(过去 30 天)
Hi,
I want plot two graphs on same plot but with different x axis limits. Just given in the figure (a) attached to this question. How can I do it?
Second, if two plots are making crossover/overlapping at some points. Is it possible two a fill any color (yellow) in the overlapped area. as shown in the attached figure (b)?
Regards,
Ahmed

采纳的回答

Pavan Guntha
Pavan Guntha 2021-7-27
Hi Nisar,
(1) You could use axes to add multiple axes to the same figure & then alter their properties as per your requirements. You could also use text command to add text to the plot. Example:
figure(1)
ax1 = axes;
ax2 = axes;
x1 = [1.95:0.1:2.95];
y1 = 2.5*ones(length(x1),1);
x2 = [-0.5:0.1:0.5];
y2 = 3*ones(length(x2),1);
plot(ax1,x1,y1,'r');
hold on
plot(ax2,x2,y2,'b');
hold off
ax2.YLim = [1 5];
ax1.YLim = ax2.YLim;
ax2.XLim = [-2 0.5];
ax1.XLim = [1.95 2.95];
ax2.Visible = "off";
set(ax1,'Yticklabel',{})
set(ax1,'Xticklabel',{})
(2) You could use patch function to fill the overlapped area in the plot. Example:
x=0:0.1:10;
y1 = randn(1,length(x));
y2 = randn(1,length(x));
figure
hold all
plot(x,y1)
plot(x,y2)
patch([x fliplr(x)], [y1 fliplr(y2)], 'g')
hold off
Hope this helps!
  4 个评论
Nisar Ahmed
Nisar Ahmed 2021-7-29
@Star Strider Thank you very much for your detail reply. Yes, it is solved.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by