Borrar filtros
Borrar filtros

How can I plot my figures like attached plots?

2 visualizaciones (últimos 30 días)
Nisar Ahmed
Nisar Ahmed el 21 de Jul. de 2021
Comentada: Nisar Ahmed el 29 de Jul. de 2021
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

Respuesta aceptada

Pavan Guntha
Pavan Guntha el 27 de Jul. de 2021
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 comentarios
Star Strider
Star Strider el 29 de Jul. de 2021
See my latest Comment for the rotated version.
Nisar Ahmed
Nisar Ahmed el 29 de Jul. de 2021
@Star Strider Thank you very much for your detail reply. Yes, it is solved.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Line Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by