Bugs in FullGraphics and AbsoluteOptions and temporary workaround
- To: mathgroup at smc.vnet.net
- Subject: [mg103473] Bugs in FullGraphics and AbsoluteOptions and temporary workaround
- From: Alexey <lehin.p at gmail.com>
- Date: Wed, 23 Sep 2009 23:51:09 -0400 (EDT)
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 :( On 30 Oct 2007, 12:14, "David Park" <djmpark at comcast.net> wrote: > In Version 6 a new alternative form for specifying FrameTicks was introduced > but AbsoluteOptions does not recognize them. > > Here is the original style that works fine: > > plota = Plot[5 Sin[x], {x, 0, 15}, > Frame -> True, > FrameTicks -> {Automatic, Automatic, None, None}] > > Short[AbsoluteOptions[plota, FrameTicks], 5] > > Here is the new style that AbsoluteOptions does not recognize: > > plotb = Plot[5 Sin[x], {x, 0, 15}, > Frame -> True, > FrameTicks -> {{Automatic, None}, {Automatic, None}}] > > Short[AbsoluteOptions[plotb, FrameTicks], 5] > > gives errors and the incorrect FrameTicks. > > -- > David Park > djmp... at comcast.nethttp://home.comcast.net/~djmpark/ On 24 Dec 2007, 13:52, "David Park" <djmpark at comcast.net> wrote: > I believe there is a bug in AbsoluteOptions for PlotRange when the PlotRange > is determined by an Arrow. Here are two different cases using first an Arrow > and then a Line instead of the Arrow. Correct results are obtained for the > Line and incorrect results are obtained for the Arrow. > > plot1 = > > Graphics[ > > {Arrow[{{0, -1}, {0, 0}}], AbsolutePointSize[6], Point[{-1, 0}], > > Point[{1, 0}]}, > > PlotRange -> All, > > Frame -> True] > > AbsoluteOptions[plot1, PlotRange] > > plot1= > > Graphics[ > > {Line[{{0,-1},{0,0}}],AbsolutePointSize[6],Point[{-1,0}],Point[{1,0}]}, > > PlotRange->All, > > Frame->True] > > AbsoluteOptions[plot1,PlotRange] > > plot2 = > > Graphics[ > > {Arrow[{{0, -1}, {0, 0}}]}, > > PlotRange -> All, > > Frame -> True] > > AbsoluteOptions[plot2, PlotRange] > > plot2 = > > Graphics[ > > {Line[{{0, -1}, {0, 0}}]}, > > PlotRange -> All, > > Frame -> True] > > AbsoluteOptions[plot2, PlotRange] > > David Park > > djmp... at comcast.net > > <http://home.comcast.net/~djmpark>http://home.comcast.net/~djmpark