2
$\begingroup$

I am trying to plot one point on a graph. I put in Plot[{3, 1}, {x, -2, 5}], but I get a line. How can I put in just one point?

$\endgroup$
2
  • 2
    $\begingroup$ ListPlot[{{3, 1}}, PlotRange -> {{-2, 5},Automatic}] $\endgroup$
    – andre314
    Jan 9, 2018 at 0:12
  • $\begingroup$ Take a look at Graphics, Point and friends. $\endgroup$
    – Kuba
    Jan 10, 2018 at 9:11

2 Answers 2

2
$\begingroup$

Normally, one does't plot discrete points with Plot, which is mainly intended for more or less continuous functions. But it can be done.

Plot[{}, {x, -2, 5},
  PlotRange -> {{-2, 5}, {0, 1.5}},
  Epilog -> {AbsolutePointSize[5], Point[{3, 1}]}]

plot

However, ListPlot is the function provided for plotting point data. For your single point you could write it like this:

ListPlot[{{3, 1}}, PlotRange -> {{-2, 5}, {0, 1.5}}]

which gives the same plot as shown above.

$\endgroup$
3
$\begingroup$
Show[Graphics[Point[{3, 1}]], PlotRange -> {{0, 4}, {-2, 5}}, 
 Axes -> Automatic]
$\endgroup$
1
  • 4
    $\begingroup$ This can be shortened to Graphics[Point[{3, 1}], PlotRange -> {{0, 4}, {-2, 5}}, Axes -> Automatic] $\endgroup$
    – Bob Hanlon
    Jan 9, 2018 at 2:15

Not the answer you're looking for? Browse other questions tagged or ask your own question.