Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1999

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

Search the Archive

Re: Clippling of polygons within a defined region

  • To: mathgroup at
  • Subject: [mg18991] Re: Clippling of polygons within a defined region
  • From: "Allan Hayes" <hay at>
  • Date: Tue, 3 Aug 1999 13:44:36 -0400
  • References: <7nrf6u$>
  • Sender: owner-wri-mathgroup at


The same problem arises with big points, thick lines and with text.
Here is an first attempt at dealing with it.

Make an example for treatment

gr = Show[Graphics[{Polygon[{{-1, 0}, {2, -2}, {2, 1}}],
        PointSize[.5], Point[{1, 1}]}],
    Frame -> True, FrameTicks -> True,
    PlotRange -> {{0, 1}, {0, 1}}

Defint the masking function

Masked[gr_Graphics, st___] :=
  Module[{fat, pr, mask, e, x1, x2, y1, y2},
    (*get the explicit graphics for frame, and frameticks*)
    fat = Delete[FullGraphics[gr], {1, 1}];
   (*get the explicit plotrange for gt*)
   {{x1, x2}, {y1, y2}} = pr =  PlotRange[gr];
    (*calculate a suitable mask with style st*)
    e = Max[x2 - x1, y2 - y1];
    mask =
          Polygon[{{x1, y1}, {x2, y1}, {x2, y2}, {x1, y2}, {x1, y1},
              {x1 - e, y1 - e}, {x1 - e, y2 + e}, {x2 + e, y2 + e}, {x2 + e,
                y1 - e}, {x1 - e, y1 - e}}]}];
    (*show the graphics in the right order*)
    Show[gr, mask, fat, PlotRange -> pr]]

One undesirable feature of this is that we are relying the hidden frame and
ticks in gr to make room for the versions in fat.

Masked[gr, Hue[.2, .2, 1]]

Allan Hayes
Mathematica Training and Consulting
Leicester UK
hay at
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565

John Tanner <john at> wrote in message
news:7nrf6u$ie2 at
> With most Graphics functions, "PlotRange" clips plots to within defined
> (rectangular) areas, and when the option Frame is used, the clipping
> occurs at the frame boundary.
> Unfortunately, while this clipping applies correctly to Line, Point
> etc., Polygons are not clipped at all in the presence of the Frame
> option: these appear within the whole visible area (obscuring the axes
> etc.) and not just within the PlotRange.
> It is possible to force the clipping by brute force by adding an extra
> Polygon masking all but the wanted region, with colour of White: however
> this now also masks the axes of the Frame!
> (1) Is there a better way of clipping Polygons, since PlotRange is
> ineffective?
> (2) Is there a way of forcing the Frame and Axes to be plotted last
> instead of first, thus plotting on top of a White Polygon?
> --
>   from -   John Tanner                 home -  john at
>   mantra - curse Microsoft, curse...   work -  john.tanner at
> I hate this 'orrible computer,  I really ought to sell it:
> It never does what I want,      but only what I tell it.

  • Prev by Date: Re: HypergeometricPFQ Question
  • Next by Date: Re: loading combinatorica
  • Previous by thread: RE: RE: How can I control FindMinimum's behavior?
  • Next by thread: Re: Clippling of polygons within a defined region