2
$\begingroup$

I would like to draw a point on a curve or on a surface. For example, I would like to plot the point $(1,1,\sqrt{2})$ with a special color.

Plot3D[{Sqrt[4 - x^2 - y^2]}, {x, 0, 2}, {y, 0, 2}, 
  PlotStyle -> Blue, AxesLabel -> Automatic]

Or the point $(1,\sqrt{3})$ on the curve

Plot[{Sqrt[4 - x^2]}, {x, 0, 2}, PlotStyle -> Blue]

I know how to plot a plane in a 3D plot, but I don't know how to plot a straight line in such a plot. How is it done?

$\endgroup$
  • 3
    $\begingroup$ Show[ Plot3D[Sqrt[4 - x^2 - y^2], {x, 0, 2}, {y, 0, 2}, PlotStyle -> Blue, AspectRatio -> 1], Graphics3D[{Red, Sphere[{1, 1, Sqrt@2}, .1]}] $\endgroup$ – Dr. belisarius Sep 9 '15 at 17:57
  • 3
    $\begingroup$ Plot[Sqrt[4 - x^2], {x, 0, 2}, PlotStyle -> Red, Epilog -> {Blue, PointSize[Large], Point[{1, Sqrt@3}]}] $\endgroup$ – Dr. belisarius Sep 9 '15 at 18:00
5
$\begingroup$

When adding Graphics or annotations to a Plot, I like to use the Show function. It allows you to join two graphics objects together. You could use something like:

Show[Plot3D[{Sqrt[4 - x^2 - y^2]}, {x, 0, 2}, {y, 0, 2}, PlotStyle -> Blue, AxesLabel -> Automatic], Graphics3D[{Red, PointSize[.05] , Point[{1, 1, Sqrt@2}]}]]

Of course you can substitute Red for your special color, and use the following to make a sphere instead of a point.

Sphere[{1, 1, Sqrt@2}, .2]

For the 2D plot, You can use the same Show technique but with Graphics instead of Graphics 3D

Show[Plot[{Sqrt[4 - x^2]}, {x, 0, 2}, PlotStyle -> Blue],Graphics[{Red, PointSize[.05] , Point[{1, Sqrt@3}]}]]

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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