Message Boards Message Boards

0
|
2786 Views
|
6 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Show graphically a plotted curve and a point {0, -1} together?

Posted 4 years ago

The following notebook script can show 7 points on a plotted graph of Plot[x^2+1,{x,-3,2}],but fails to show the point {0, -1} on the graph. How can I show the point {0,-1} on the graph, too?

PlotPx = Plot[x^2 + 1, {x, -3, 2}];
PointSet = {{-3, 9}, {-2.5, 5.75}, {-2, 4}, {3, 9}, {-1, 2}, {-0.5, 
    1.75}, {0, -1}, {0, 2}, {1, 4}, {2, 8}};
PointMap = Map[Point, PointSet];
Show[PlotPx, Graphics[{PointSize[0.01], PointMap}], 
 AspectRatio -> Automatic, Axes -> True,
 AxesLabel -> {x, "y=P(x)"}]
6 Replies

You can also use Epilog[]:

Plot[x^2 + 1, {x, -3, 2}, Epilog -> Map[Point, data]]

Regards

Neil

POSTED BY: Neil Singer

Dear Mr. Neil Singer:I thank you very much for your quick answer to my elementary question. Your suggestion greatly helped me come out of the quagmire I have been struggling with the problem for more tna three days!

I know only little about the "Epilog", but will spend some time to learn that.

Thank you very much again!

Sincerely, Hiroshi Matsumura (June 26, 2020)

Dear Mr. Hans Milton: I am very greatful to your quick answer to my elementary question.
At last I could find a way out of the quagmire I have been struggling with the problem for more than three days!

Thank you very much again!

Sincerely, Hiroshi Matsumura (June 26, 2020)

Posted 4 years ago

Another way is to specify PlotRange -> All as an option to Show

Show[
    PlotPx, Graphics[{PointSize[0.01], PointMap}],
    AspectRatio -> Automatic, Axes -> True, AxesLabel -> {x, "y=P(x)"},
    PlotRange -> All
 ]
POSTED BY: Hans Milton
Posted 4 years ago

I believe that I remember that Show takes the PlotRange from the first argument. So force the PlotRange to include your all your points

PlotPx = Plot[x^2 + 1, {x, -3, 2},PlotRange->{-1.5,6}];

And that includes your Point{{0,-1}]

There are almost always more than one way of doing anything with Mathematica..

POSTED BY: Bill Nelson

Dear Mr. Bill Nelson: Your instruction worked fine, and solved my problem which I have been struggling with for three days! I am very grateful to your quick response to my elementary question.
Thank you very much again!

Sincerely, Hiroshi Matsumura (June 26, 2020)

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract