You can display graphics primitives in your plot by using the Show
command
Show[
Plot[{1/Sqrt[2*Pi] Exp[-1/2*x^2]}, {x, -3, 3}, Filling -> Axis],
Graphics[Line[{{1.6, 0}, {1.6, 0.4}}]],
Graphics[{Thick, Red, Line[{{-0.4, 0}, {-0.4, 0.4}}]}],
Graphics[Text["Φ", {-.6, 0.38}]],
Graphics[Text["μ", {2, 0.1}]]
]
You can actually just combine all the Graphics
objects into one list but I always keep them separate for legibility and editability since otherwise you have to remember to switch back and forth between e.g. color and line weight specifications.
Show[
Plot[{1/Sqrt[2*Pi] Exp[-1/2*x^2]}, {x, -3, 3}, Filling -> Axis],
Graphics[
{Line[{{1.6, 0}, {1.6, 0.4}}],
Thick, Red,
Line[{{-0.4, 0}, {-0.4, 0.4}}],
Thin, Black,
Text["Φ", {-.6, 0.38}],
Text["μ", {2, 0.1}]}
]
]
You can also achieve the same result by using the Epilog
or Prolog
option for Plot
Plot[
{1/Sqrt[2*Pi] Exp[-1/2*x^2]},
{x, -3, 3},
Filling -> Axis,
Prolog ->
{Line[{{1.6, 0}, {1.6, 0.4}}],
Thick, Red,
Line[{{-0.4, 0}, {-0.4, 0.4}}],
Thin, Black,
Text["Φ", {-.6, 0.38}],
Text["μ", {2, 0.1}]}
]
The difference between Prolog
and Epilog
is in placing your graphics primitives behind or in front of the Plot
, this may be important in certain circumstances.
Once you have composed your plot you can use the standard Export
command to save it to a format of your choosing.
GridLines
option ofPlot[]
? $\endgroup$Epilog
and the graphics primitivesLine[]
andText[]
... $\endgroup$Graphics > Drawing Tools
. $\endgroup$Eiplog
is working by the way! thanks! the problem with the example used in the mathematica documentation concerning epilog, found here reference.wolfram.com/mathematica/ref/Line.html is that the functionLine[]
is for a continuous selection of data points. I want two discrete unjoined lines. Any idea how that could be accomplished? thanks! $\endgroup$Epilog
, e.g.Epilog -> {Line[{pt1, pt2}], Line[{pt3, pt4}]}
would draw two unconnected lines. Even with oneLine
statement you can draw unconnected lines by doing something likeLine[{{pt1, pt2}, {pt3, pt4}}]
. $\endgroup$