Need to plot points
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Hello every one
I have an assignment,PLEASE , I need to draw a group of points
(x,y1) in red colour
(x,y2) in blue colour
(x,y3) in green
(x,y4) in pink
(x,y5) in yallow
at the same time in the form of specifying their points only and in different colors to distinguish them and with the extension of certain numbers to the x-axis shown in the picture
I drew the points in Excel, but the only error in the drawing is the presence of a straight line connecting the points, and this is not what I want. In addition, in Excel, I cannot enlarge the drawing, nor can I show a clearer picture of the points that contain 0.000, the points appear as on the zero axis, which they are not
I searched a lot with Matlab commands in drawing and found it
scatter(x,y1,'ro') ...
I used it in the attached file, but the output of the drawing is not in the description I mentioned above
is possible to plot in matlab ??
if any prof can help me thanks alot.
0 Commenti
Risposta accettata
Jan
il 6 Mar 2022
Modificato: Jan
il 6 Mar 2022
scatter() is a "high-level" function for drawing. Such functions clear the contents of the axes automatically. To collect the output, use hold on or equivalently:
axes('nextplot', 'add'); % equivalent to: hold on
% Then let the drawing follow:
scatter(x,y1,'ro')
scatter(x,y2,'b*')
scatter(x,y3,'g')
scatter(x,y4,'p')
scatter(x,y5,'y')
9 Commenti
Più risposte (1)
Les Beckham
il 8 Mar 2022
Modificato: Les Beckham
il 8 Mar 2022
It isn't pretty but this is the closest I could come up with to reproducing what you appear to want.
x =[ 1 2 3 4 10 1 2 3 4 10 1 2 3 4 10 ];
y1=[ 2 1 5 3 1 0.2 0.1 0.5 0.3 0.1 2.00E-03 1.00E-03 5.00E-03 3.00E-03 1.00E-03 ];
y2=[ 4 3 7 4 4 0.4 0.3 0.7 0.4 0.4 4.00E-03 3.00E-03 7.00E-03 4.00E-03 4.00E-03 ];
y3=[ 6 5 8 7 6 0.6 0.5 0.8 0.7 0.6 6.00E-03 5.00E-03 8.00E-03 7.00E-03 6.00E-03 ];
y4=[ 5 4 8 5 5 0.4 0.3 0.7 0.4 0.4 4.00E-03 3.00E-03 7.00E-03 4.00E-03 4.00E-03 ];
y5=[ 6 6 9 8 7 0.6 0.5 0.8 0.7 0.6 6.00E-03 5.00E-03 8.00E-03 7.00E-03 6.00E-03 ];
figure(1)
plot(1:15, y1, 'x', 1:15, y2, 'sq', 1:15, y3, '^', 1:15, y4, '+', 1:15, y5, 'o');
xticks(1:15)
xticklabels({'1' '2' '3' '4' '10' '1' '2' '3' '4' '10' '1' '2' '3' '4' '10'})
grid on
I think it looks better with the lines.
figure(2)
plot(1:15, y1, 'x-', 1:15, y2, 'sq-', 1:15, y3, '^-', 1:15, y4, '+-', 1:15, y5, 'o-');
xticks(1:15)
xticklabels({'1' '2' '3' '4' '10' '1' '2' '3' '4' '10' '1' '2' '3' '4' '10'})
grid on
2 Commenti
Vedere anche
Categorie
Scopri di più su Annotations in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!