how to create 3 scatter plots in same one figure in different color
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Naoki Ishibashi
le 9 Oct 2016
Réponse apportée : Image Analyst
le 9 Oct 2016
I have three x,y data sets (TS01-TA01, TS10-TA10, TS20-TA20), and I want to read these data sets and create 3 scatter plots in same one figure in different color. but following my code does not overlap. please give me advice.
x1filename = ('TS20040101.txt');
y1filename = ('TA20040101.txt');
x1 = load(x1filename);
y1 = load(y1filename);
x2filename = ('TS20040110.txt');
y2filename = ('TA20040110.txt');
x2 = load(x1filename);
y2 = load(y1filename);
x3filename = ('TS20040120.txt');
y3filename = ('TA20040120.txt');
x3 = load(x1filename);
y3 = load(y1filename);
scatter(x1,y1);
hold on;
scatter(x2,y2,[],'r');
scatter(x3,y3,[],'c');
hold off;
xlabel('surface temperature');
ylabel('near-surface air temperature');
1 commentaire
Réponse acceptée
Image Analyst
le 9 Oct 2016
When you load x2 and y2, you're passing in the x1 and y1 filenames, not the x2 and y2 filenames like you should. Same problem for #3 - you're passing in the x1 filenames instead of the x3 filenames. To fix:
x1filename = ('TS20040101.txt');
y1filename = ('TA20040101.txt');
x1 = load(x1filename);
y1 = load(y1filename);
x2filename = ('TS20040110.txt');
y2filename = ('TA20040110.txt');
x2 = load(x2filename);
y2 = load(y2filename);
x3filename = ('TS20040120.txt');
y3filename = ('TA20040120.txt');
x3 = load(x3filename);
y3 = load(y3filename);
scatter(x1,y1);
hold on;
scatter(x2,y2,[],'r');
scatter(x3,y3,[],'c');
hold off;
xlabel('surface temperature');
ylabel('near-surface air temperature');
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Graphics Object Programming 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!