Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2000
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2000

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Q: Axes on top of graphics primitives?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg22954] Re: [mg22908] Q: Axes on top of graphics primitives?
  • From: Preston Nichols <pnichols at wittenberg.edu>
  • Date: Fri, 7 Apr 2000 02:54:36 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

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.

I hope this helps.

Preston Nichols
Mathematics and Computer Science
Wittenberg University






  • Prev by Date: Re: best solution?
  • Next by Date: Re: Apparently easy ODE
  • Previous by thread: RE: Q: Axes on top of graphics primitives?
  • Next by thread: Re: Re: Q: Axes on top of graphics primitives?