The fact that your plot doesn't show "too high" values isn't specific to LogPlot
, has nothing to do with the PlotRange
you specified, and also isn't due to the values being "too high". It is the result of the initial sampling of the plot points. According to my observations so far, no Plot
includes the lower and upper limit specified for the variable. For example Plot[f, {x, xmin, xmax}
plots f for xmin < x < xmax
and not for xmin <= x <= xmax
, meaning f is plotted for the open interval $(xmin, xmax)$ and not for $[xmin, xmax]$.
First, one way to make your LogPlot
look like your ListLogPlot
LogPlot[1/x, {x, 0, 1}, PlotRange -> {{-.1, 1}, All}, Frame -> True,
PlotPoints -> 1000001, MaxRecursion -> 0,
PlotRangePadding -> {{0, 0}, {Scaled[0.02], Scaled[0.05]}}]
Using {x, 0, 1}
together with PlotPoints -> 1000001
makes the plot start at 1.*10^-12
and end at 1 - 1.*10^-12
. The PlotRangePadding
is only added for an easier visual comparison, as the default is different for LogPlot
and ListLogPlot
.
Using such a high number of PlotPoints
makes generating the plot much slower than using your ListLogPlot
, which seems to be the better choice for this situation.
The problem generalized
Even a very simple plot like
Plot[1, {x, 0, 1}]
does not start at x == 0
and end at x == 1
, it starts at x == 2.040816326530612*^-8
and ends at x == 0.999999979591837
. The only difference is, that here it isn't as obvious as in your 1/x
case.
It is also worth pointing out, that this is not limited to the case where xmin
is 0
.
How to observe what is going on.
There is an extensive How does Plot work? Q&A that already analyses the inner workings of Plot
. However, the problem that the function isn't plotted for xmin
and xmax
isn't part of it.
Let's first define a function that will print out its input and evaluate to 1
probe[x_] := (Print[NumberForm[x, Infinity]]; 1)
Using this function inside plot and extracting all the x values plotted
Cases[Plot[probe[x], {x, -1, 1}, PlotPoints -> 11, MaxRecursion -> 0,
PlotRange -> All], Line[x_] :> NumberForm[x[[All, 1]], Infinity], Infinity] // Flatten
shows, that the function probe
is first evaluated for xmin == -1
, than for an x value slightly bigger, than probe
is evaluated symbolically (could be suppresses by defining probe
only for numerical values) and finally probe
is evaluated at the 11 plot points starting with a value between the first two evaluations.
PlotRange -> {{-.1, 1}, {0, 10^12}}
or so. $\endgroup$PlotRange
or ignoring "points which are going to "too high" ". The reason why there are no higher values shown is that the first x-value at which the function1/x
is evaluated isCases[LogPlot[1/x, {x, 10^-12, 1}, PlotRange -> {{-.1, 1}, All}, Frame -> True], Line[x_] :> x[[1, 1]], Infinity]
=>{2.04092*10^-8}
. $\endgroup$PlotPoints
helps, but doesn't solve the problem completely. $\endgroup$