I can suggest the following Ticks
hack:
pl = Plot[Sin[x], {x, 0, 10}];
Reap[Rasterize[Show[pl, Ticks -> {Sow[{##}] &, Sow[{##}] &}],
ImageResolution -> 1]][[2, 1]]
=> {{-0.208333, 10.2083}, {-1.04167, 1.04167}}
The trick is that real PlotRange
is determined by the FrontEnd, not by the Kernel. So we must force the FrontEnd to render the graphics in order to get tick functions evaluated. This hack gives the complete PlotRange
with explicit value of PlotRangePadding
added.
More general solution taking into account a possibility that pl
has non-standard value of DisplayFinction
option and that it may have Axes
option set to False
:
completePlotRange[plot_] :=
Last@Last@
Reap[Rasterize[
Show[plot, Ticks -> (Sow[{##}] &), Axes -> True,
DisplayFunction -> Identity], ImageResolution -> 1]]
On the Documentation page for PlotRange
under the "More information" one can read an important note about AbsoluteOptions
: "AbsoluteOptions
gives the explicit form of PlotRange
specifications when Automatic
settings are given" (highlighting is mine). So it seems that the Documentation does not guarantee that AbsoluteOptions
will give correct values for PlotRange
when it is not Automatic
for all coordinates.