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?
2 Answers
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}]}]
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.
Show[Graphics[Point[{3, 1}]], PlotRange -> {{0, 4}, {-2, 5}},
Axes -> Automatic]
-
4$\begingroup$ This can be shortened to
Graphics[Point[{3, 1}], PlotRange -> {{0, 4}, {-2, 5}}, Axes -> Automatic]
$\endgroup$ Jan 9, 2018 at 2:15
ListPlot[{{3, 1}}, PlotRange -> {{-2, 5},Automatic}]
$\endgroup$Graphics
,Point
and friends. $\endgroup$