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.

 Réponse acceptée

Jan
Jan le 6 Mar 2022
Modifié(e) : Jan le 6 Mar 2022

0 votes

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 commentaires

hasan s
hasan s le 6 Mar 2022
Modifié(e) : hasan s le 6 Mar 2022
thanks prof. Jan for your help
but I need x-axes as
1 2 3 4 10 1 2 3 4 10 1 2 3 4 10
is there possible to add tool to draw that
hasan s
hasan s le 8 Mar 2022
thank you very much prof Jan
I really benefited from your answer... thanks alot
Jan
Jan le 8 Mar 2022
I'm glad, if I can help.
What does "x-axes as 1 2 3 4 10 1 2 3 4 10 1 2 3 4 10" mean? I'm not sure, how this should look like.
hasan s
hasan s le 8 Mar 2022
The drawing required of me should appear as in the first attached image of the Excel program, but without a straight line connecting the points.
therefore ... I had to repeat the drawing, and it became several drawings instead of what was required of me as one drawing on an x-axis
Thank you so much prof. Jan
Perhaps this helps:
data = rand(1, 10);
plot(1:10, data, 'rx')
hold on
plot(1:10, 1-data, 'bo')
hasan s
hasan s le 8 Mar 2022
Modifié(e) : hasan s le 8 Mar 2022
thanks alot prof. Jan
but x-axis is still 1 2 ... 10
I need x axis as 1 2 ... 10 1 2 ... 10 1 2 .... 10 with their graph
It's like after I start drawing (x, y1) from x=1 ... 10, after 10 start the new count from x=1 ...10 , in order to start drawing (x, y2)
I will try in Your last idea..I'm trying to understand it
thank you very very much
I still do not understand, what this means: "x axis as 1 2 ... 10 1 2 ... 10 1 2 .... 10 with their graph"
Maybe:
axes('XLim', [1, 15], ...
'Xtick', 1:15, ...
'XTickLabel', sprintfc('%d', [1 2 3 4 10]))
If there are more ticks than labels, the labels are repeated.
hasan s
hasan s le 8 Mar 2022
Excellent programming , thanks alot prof. Jan
This is what I want
Now I have to understand How do I add the commands to get the drawing...
hasan s
hasan s le 8 Mar 2022
Thank you very much for your help

Connectez-vous pour commenter.

Plus de réponses (1)

Les Beckham
Les Beckham le 8 Mar 2022
Modifié(e) : Les Beckham le 8 Mar 2022

1 vote

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 commentaires

hasan s
hasan s le 8 Mar 2022
Excellent programming too
This is exactly what I need
Thank you very much prof. Les Beckham for your help
Les Beckham
Les Beckham le 8 Mar 2022
You are quite welcome.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Data Exploration dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by