Re: Clippling of polygons within a defined region

• To: mathgroup at smc.vnet.net
• Subject: [mg18991] Re: Clippling of polygons within a defined region
• From: "Allan Hayes" <hay at haystack.demon.co.uk>
• Date: Tue, 3 Aug 1999 13:44:36 -0400
• References: <7nrf6u\$ie2@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```John,

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}}
]

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];
Graphics[{st,
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.

Allan
---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565

John Tanner <john at janacek.demon.co.uk> wrote in message
news:7nrf6u\$ie2 at smc.vnet.net...
> 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 janacek.demon.co.uk
>   mantra - curse Microsoft, curse...   work -  john.tanner at gecm.com
> 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