Is there a way to include specific points in a plot?
The Exclusions
option of Plot
(and related plotting functions) allows us to tell Plot
to avoid specific points, (e.g. because we know the plotted function is singular at that point). I want to do the opposite, tell Plot
to include specific points in the initial points in the plot (before any recursion), because we know the plotted function will have a particularly sharp feature at that point, that might otherwise be missed.
As MWE consider the following:
f[x_?NumericQ] := Exp[-10^4 (x - \[Pi])^2]
Plot[f[x], {x, 5/2, 4}, PlotRange -> 1, PlotPoints -> 5]
With these settings Plot
misses the Gaussian peak at x=Pi
. Is there a way to tell Plot
to specifically include x=Pi
in the plotted points. (Of course, we can just krank up the PlotPoints
to make sure we hit the feature, but this is not viable in the real world application I am dealing with.)
PlotPoints -> 5
is too low. IncreasePlotPoints
and useMaxRecursion
, e.g.,PlotPoints -> 6, MaxRecursion -> 10
$\endgroup$Show
andGraphics
along withPlotRange
to getShow[Plot[f[x],{x,5/2,4},PlotRange->{{5/2,4},{0,1}}, PlotPoints->5],Graphics[Point[{Pi,Exp[0]}]]]
to include a specific point with a plot. Then you can deal with pushing the plot resolution to be what you want. $\endgroup$