Anyway to plot one point

조회 수: 3,524 (최근 30일)
nas illmatic
nas illmatic 2019년 3월 17일
답변: MathWorks Support Team 2022년 9월 27일
Is there anyway in Matlab to plot one point?
For example: plot(1,2) returns simply a blank plot
  댓글 수: 1
per isakson
per isakson 2019년 3월 17일
Try
plot(1,2,'d')

댓글을 달려면 로그인하십시오.

채택된 답변

Nicholas Ayres
Nicholas Ayres 2020년 8월 20일
I'm a bit late to the party, BUT...
The issue this person is having is that the default plot type is just a "line" which connects points together. If there is only one point, it has nothing to connect it to. You need to add a marker.
Using any of the following characters after your x,y coordinates will produce these markers on your plot:
'o','+','*','.','x','s','d','^','v','>','<','p',h'
E.g.
plot(1,2,'.')
will just plot a dot at (1,2). You can combine this with line styles and colors to get a lot of variety in your plots. (my favourite is '.-', which puts dots at all the points and connects them together)
Specifically the section on "LineSpec" if you're short on time. It's worth the read as this provides a very simple way to pretty up your graphs a bit (and explains what the character inputs I listed above represent. This is the most common plotting method you're going to use and the syntax for the "LineSpec" works with a myraid of other plotting types, so it's worthwhile to know what's going on.

추가 답변 (3개)

Sajeer Modavan
Sajeer Modavan 2019년 3월 19일
scatter(1,2)

MathWorks Support Team
MathWorks Support Team 2022년 9월 27일
By default, “plot” displays a line between two or more points with no markers. When there is only one point, nothing displays unless you specify a marker. To display a marker at one point, call the “plot” function and specify the marker using the “LineSpec” argument. For example, display the point (1,2) using a circular marker:
x = 1;
y = 2;
plot(x,y,"o")
You can select from a variety of different markers. For a full list, see the "Marker" property of the “Line” object.
Alternatively, call the “scatter” function, which displays a circular marker at the specified location by default:
scatter(x,y)

MathWorks Support Team
MathWorks Support Team 2022년 9월 27일
By default, “plot” displays a line between two or more points with no markers. When there is only one point, nothing displays unless you specify a marker. To display a marker at one point, call the “plot” function and specify the marker using the “LineSpec” argument. For example, display the point (1,2) using a circular marker:
x = 1;
y = 2;
plot(x,y,"o")
You can select from a variety of different markers. For a full list, see the "Marker" property of the “Line” object.
Alternatively, call the “scatter” function, which displays a circular marker at the specified location by default:
scatter(x,y)

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by