How can I plot my figures like attached plots?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Nisar Ahmed
le 21 Juil 2021
Commenté : Nisar Ahmed
le 29 Juil 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
0 commentaires
Réponse acceptée
Pavan Guntha
le 27 Juil 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',{})
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!
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Annotations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!