Anyway to plot one point

5.517 views (last 30 days)
nas illmatic
nas illmatic on 17 Mar 2019
Answered: Nicholas Ayres on 20 Aug 2020
Is there anyway in Matlab to plot one point?
For example: plot(1,2) returns simply a blank plot
  1 Comment
per isakson
per isakson on 17 Mar 2019

Sign in to comment.

Answers (2)

Nicholas Ayres
Nicholas Ayres on 20 Aug 2020
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:
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.


Community Treasure Hunt

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

Start Hunting!