How can I extract the used plot range from a plot?
I create a plot:
plot = Plot[Sin[x], {x, 0, 2 \[Pi]}, Frame -> True,
PlotRangePadding -> {0, Scaled[.2]}]
When I try to extract the plot range with: AbsoluteOptions or PlotRange, I incorrectly get:
{{0., 6.28319}, {-1., 1.}}
This misses the plot range padding.
Manually adding it
{px0, py0} = Quiet[AbsoluteOptions[plot, PlotRange]][[1, 2]];
{xpad, ypad} =
Map[Identity @@ # &,
Quiet[AbsoluteOptions[plot, PlotRangePadding]][[1, 2]], {2}];
{lx, ly} = Differences[#][[1]] & /@ {px0, py0};
{px, py} =
MapThread[{#1[[1]] - #3[[1]] #2, #1[[2]] + #3[[2]] #2} &, {{px0,
py0}, {lx, ly}, {xpad, ypad}}]
does not lead to the correct answer either. I get {{0., 6.28319}, {-1.4, 1.4}} instead of {{0., 6.28319}, {-1.666667, 1.666667}}.
