Need to plot points
조회 수: 1 (최근 30일)
이전 댓글 표시
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
채택된 답변
Jan
2022년 3월 6일
편집: Jan
2022년 3월 6일
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')
추가 답변 (1개)
Les Beckham
2022년 3월 8일
편집: Les Beckham
2022년 3월 8일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!