# Add a vertical dashed line at a specific point in the plot

I have a function g[t] and I want to add (in the x-axis, colored red for example) the point of intersection of g[t] with the x-axis ([g[t]==0) named g0 , and a point g1 that satisfy the equation g1=g0/3, and to add the vertical dashed line from the plot to x-axis in the g1 point . The function would look like this :

g[t_] = 1 - 1/(Exp[990/t] - 1); Plot[g[t], {t, 0, 1500}]


The output would look similar to: • Please edit the picture by hand or edit the post to include something that is similar to what you want. In your explanation g1=g0/3  would be zero since g0 is at zero so improve the explanation further, if required. Thanks.
– Syed
Oct 10, 2022 at 17:14
• You can add an Epilog option to your Plot command where you can specify as many lines as needed using Line. Oct 10, 2022 at 17:19

ClearAll[g]
g[t_] = 1 - 1/(Exp[990/t] - 1);

mesh = {2/3, 1/3, 0};
meshlabels = {"g2", "g1", "g0"};


### 1. DisplayFunction + MeshFunctions + Mesh

Use a custom DisplayFunction to add labels and drop lines to mesh points specified using the options MeshFunctions and Mesh:

displayFunction = ReplaceAll[
p : {__Point} :>
Dashed, Line[{#2, {1, 0} #2}]} &]@{meshlabels, p[[All, 1]]}}]@*
Normal;

Plot[g[t], {t, 0, 1500},
MeshFunctions -> {#2 &},
Mesh -> {mesh},
MeshStyle -> Directive[Red, PointSize @ Large],
DisplayFunction -> displayFunction] ### 2. PlotHighlighting

In versions 13.3+, you can also use the option PlotHighlighting to specify the points to be highlighted, their labels and drop lines:

highlights = MapApply[Placed[
{{"XYLabel", <|LeaderSize -> {10, 90 Degree},
LabelingFunction -> (#), Appearance -> "Framed", Background -> White|>},
"YNearestPoint",
{"XDropline", <|"Style" -> Directive[Thick, Dashed, Red]|>}}, {#2}] &]@
Transpose[{Function /@ meshlabels, mesh}];

Plot[g[t], {t, 0, 1500}, PlotHighlighting -> highlights] ### 3. ListPlot + Filling + Show

pts = Quiet@Transpose[{InverseFunction[g] /@ mesh, mesh}];

Show[Plot[g[t], {t, 0, 1500}],
Filling -> Axis,
PlotStyle -> Directive[Red, PointSize@Large],
FillingStyle -> Directive[ Thick, Dashed]]] Or use ListPlot, Filling and Callout.

Clear[g, plot, root];
g[t_] = 1 - 1/(Exp[990/t] - 1);
plot = Plot[g[t], {t, 0, 1500}];
root = NSolveValues[{g[t] == 0, t > 0}, t][];
Show[plot,
ListPlot[
MapAt[Callout[#, Subscript[g, 1], Above] &, 1]@
MapAt[Callout[#, Subscript[g, 0], Above] &, 2]@
Table[{t, g[t]}, {t, {root/3, root}}], Filling -> Bottom,
FillingStyle -> Directive[Red, Dashed],
PlotStyle -> {Black, PointSize[Large]}], PlotRangePadding -> .2] Assuming you meant that g1 is one third of the value at which g is zero.

g[t_] = 1 - 1/(Exp[990/t] - 1);
Plot[
g[t],
{t, 0, 1500},
Epilog -> ({
{PointSize@Large, Red, Point@{t0, 0}}        (*g0 point*),
{Text["g0", 1.05 {t0, 0.1}]}                 (*g0 label*),
{PointSize@Large, Red, Point@{g1, g[g1]}}    (*g1 point*),
{Text["g1", 1.1 {g1, g[g1]}]}                (*g1 label*),
{Dashed, Red, Line@{{g1, 0}, {t0/3, g[g1]}}} (*g1 dashed line*)
} //. {g1 -> t0/3}~Join~FindRoot[g[t0], {t0, 1500}])
(* the above line is to define g1 and and find the root g0*)
] 