Re: Re: Q: Axes on top of graphics primitives?
- To: mathgroup at smc.vnet.net
- Subject: [mg22974] Re: [mg22954] Re: [mg22908] Q: Axes on top of graphics primitives?
- From: Hartmut Wolf <hwolf at debis.com>
- Date: Sat, 8 Apr 2000 14:44:44 -0400 (EDT)
- Organization: debis Systemhaus
- References: <200004070654.CAA16476@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Preston Nichols schrieb: > > At 02:04 AM 04/06/2000 -0400, Eckhard Hennig wrote: > >In a list plot, I would like to mark a rectangular region around the axes > >origin with a gray background. The following three lines basically do what I > >want except that the axes are drawn *behind* the rectangle. Does anyone know > >an approach that allows to draw the axes on top of the gray region? > > > >lp = ListPlot[{{0, 0}}, PlotRange -> {{-2, 2}, {-2, 2}}, AspectRatio -> 1] > >region = Graphics[{GrayLevel[0.95], Rectangle[{-1, -1}, {1, 1}]}] > >Show[lp, region] > > > >-- Eckhard > > Try this; note the order of the arguments in Show: > > Show[region, FullGraphics[lp]] > > That, however, will use the AspectRatio (and other options) from region, so > you may want: > > Show[region, FullGraphics[lp], AspectRatio->1] > > or (a bit wasteful and ungraceful): > > Show[lp, region, FullGraphics[lp]] > > which renders lp twice. > > Further explanation follows: > > Explicitly given graphics primitives (such as Rectangle, or Line, or Point, > or ...) are always rendered on top of the axes and ticks (even if you put > the primitives in a Prolog option). The axes and ticks are generated from > (usually default) values of the options Axes, Ticks, AxesOrigin, etc., not > from graphics primitives. > > To get around this, you must somehow translate the axes and ticks into > explicit graphics primitives, and then Show them after any items you want > "behind" them. The simplest way to do this is to use FullGraphics. > > Depending on what you ultimately want to do with these plots, you could > construct a list of graphics primitives for the axes and tick "by hand", > completely circumventing Mathematica's built-in routines for axes and ticks. > Dear Preston, just a little remark to add to your nice solution: In[2]:= p = ParametricPlot[{Cos[t], Sin[t]}, {t, 0, 2 Pi}, PlotStyle -> {Thickness[0.02], Hue[5/6, 0.5, 1.]}, PlotRange -> {{-2, 2}, {-2, 2}}, AspectRatio -> Automatic] In[3]:= pseudop = ReplacePart[p, {}, 1] In[4]:= region = Graphics[{GrayLevel[0.95], Rectangle[{-1, -1}, {1, 1}]}] In[5]:= Show[pseudop, region, FullGraphics[p]] or to put it together Show[ReplacePart[#1, {}, 1], ##2, FullGraphics[#1]] &[p, region] might be a good compromise between function and economy. Kind regards, Hartmut
- References:
- Re: Q: Axes on top of graphics primitives?
- From: Preston Nichols <pnichols@wittenberg.edu>
- Re: Q: Axes on top of graphics primitives?