Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Bugs in FullGraphics and AbsoluteOptions and temporary workaround

3 views
Skip to first unread message

Alexey

unread,
Jul 2, 2009, 7:10:12 AM7/2/09
to
Hello,

There is one major bug in FullGraphics (as well as in Absolute
Options):
FullGraphics uses PlotRange from the AbsoluteOptions and fully ignores
PlotRangePadding (new in Mathematica version 6) and AxesOrigin (new in
2) options.
This is the reason for clipping the X-axis that we see here:

g = Plot[Sin[x], {x, 0.2, 10}]
Show[FullGraphics[g], AspectRatio -> 1/GoldenRatio]

And this is also reason for wrong Ticks specifications generated by
FullGraphics and AbsoluteOptions.

I have developed a program for generating explicit values of PlotRange
with respect to AxesOrigin and PlotRangePadding options. It is assumed
in this program that PlotRangePadding has it's default value {Scaled
[0.02], Scaled[0.02]}.
The code follows:

=======Start of code=========

g = Plot[Cos[x], {x, 0.2, 10}]

(*Generating explicit PlotRange with respect to PlotRangePadding and \
AxesOrigin*)
axsOr = AxesOrigin /. AbsoluteOptions[g];
pltR = PlotRange /. AbsoluteOptions[g];
pltRPad = PlotRangePadding /. Options[g];
Which[
pltRPad === {Scaled[0.02], Scaled[0.02]} (*The default value*),
\[CapitalDelta]x = 0.02 (pltR[[1, 2]] - pltR[[1, 1]]);
\[CapitalDelta]y = 0.02 (pltR[[2, 2]] - pltR[[2, 1]]);
pltR = pltR + {{-\[CapitalDelta]x, \[CapitalDelta]x}, {-\[CapitalDelta]
y, \
\[CapitalDelta]y}};
]
Do[
pltR[[i, 1]] = Min[axsOr[[i]], pltR[[i, 1]]];
pltR[[i, 2]] = Max[axsOr[[i]], pltR[[i, 2]]],
{i, {1, 2}}]
(*Generating the list of necessary options*)
options =
Table[opt -> (opt /. AbsoluteOptions[g]), {opt, {AxesOrigin, Axes,
AspectRatio}}]~Join~{PlotRange -> pltR};
(*We recreate original plot, but with explicit PlotRange option*)
gg = Graphics[g[[1]], options]
(*FullGraphics*)
ggg = Show[FullGraphics[gg], AspectRatio -> (AspectRatio /. Options
[g])]
(*Overlapping FullGraphics and original plot*)
Graphics[{g[[1, 1]], FullGraphics[gg][[1]]}, options, ImageSize ->
{260, 154}]


(*Generating explicit Ticks specification*)
(*This uses CustomTicks packege from \
http://library.wolfram.com/infocenter/MathSource/5599*)
Needs["CustomTicks`"]
options = Append[options, Ticks -> (LinTicks @@ # & /@ pltR)];
(*We recreate original plot, but with explicit PlotRange and Ticks
options*)
gg2 = Graphics[g[[1]], options]
(*FullGraphics*)
ggg2 = Show[FullGraphics[gg2], AspectRatio -> (AspectRatio /. Options
[g])]
(*Overlapping FullGraphics and original plot*)
Graphics[{g[[1, 1]], FullGraphics[gg2][[1]]}, options,
ImageSize -> {260, 154}]


=======End of code=========

And what I have also found about FullGraphics function:
It doesn't appear to have been updated since V2: see bottom of the
page
http://reference.wolfram.com/mathematica/ref/FullGraphics.html :(


Alexey

unread,
Jul 3, 2009, 5:35:15 AM7/3/09
to
The above-code without a bug caused by automatic wrapping:
0 new messages