how to plot two graphs ?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have two matrices to plot
A=[1 1.2
3 2.3
7 3.2
8 3 ]
and
B=[2 3.2
4 4.5
5 7
6 0 ]
I want to create a plot
plot(A(:,1),A(:,2),'r');
hold on
plot(B(:,1),B(:,2),'b');
but instead of x it should be month. Any suggestion would be appreciated in advance.
0 commentaires
Réponse acceptée
Star Strider
le 8 Mar 2016
Modifié(e) : Star Strider
le 8 Mar 2016
One approach that will use local month names:
A=[1 1.2
3 2.3
7 3.2
8 3 ]
B=[2 3.2
4 4.5
5 7
6 0 ]
dn = datenum([repmat(2016, size(A,1)+size(B,1), 1) [A(:,1); B(:,1)], ones(size(A,1)+size(B,1), 1)]); % Create Date Numbers From Months
plot(dn(1:size(A,1)) ,A(:,2),'r');
hold on
plot(dn(size(A,1)+1:end),B(:,2),'b');
datetick('x', 'mmm')
8 commentaires
Plus de réponses (1)
Chad Greene
le 8 Mar 2016
Is this what you want?
set(gca,'xtick',1:8,'xticklabel',{'jan','feb','mar','apr','may','jun','jul','aug'})
0 commentaires
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!