MathGroup Archive 1999

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

Search the Archive

Re: Clippling of polygons within a defined region

  • To: mathgroup at
  • Subject: [mg19080] Re: Clippling of polygons within a defined region
  • From: John Tanner <john at>
  • Date: Thu, 5 Aug 1999 01:35:02 -0400
  • Organization: Peace with the World
  • References: <7nrf6u$> <7o5ff4$>
  • Sender: owner-wri-mathgroup at

In article <7o5ff4$rgt at>, Allan Hayes
<hay at> writes
>The same problem arises with big points, thick lines and with text.
>Here is an first attempt at dealing with it.
>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.

Thank you very much!  That gives me exactly what I needed.  At first I
thought it was a complete solution but I now see what you mean about an
"undesirable feature".  There seems to be a small problem with
FullGraphics in terms of the position and orientation of FrameLabels and
PlotLabel (fortunately easy to overcome: before, I had absolutely

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

gr2 = Show[
Graphics[{Polygon[{{-1, 0}, {2, -2}, {2, 1}}],
 PointSize[0.5],Point[{1, 1}]}],
 Frame -> True, FrameTicks -> True,
 PlotRange -> {{0, 1}, {0, 1}},
 FrameLabel -> {"X Axis", "Y Axis"},
 PlotLabel -> "Plot Label"]

Masked[gr2, RGBColor[1, 1, 1]]

Select[ToString[#] & /@ Flatten[FullGraphics[gr2] /. Graphics -> List], 
  StringPosition[#, "Axis"] =!= {} &]

{"Text[X Axis, {0.5, -0.0202254}, {0., 1.}]",
 "Text[Y Axis, {-0.01875, 0.5}, {1., 0.}]"}

This seems to show that Text is being called with 3 arguments, missing
the "offset" argument in position 3.

Incidentally, the behaviour of Display in generating output files is
rather different from Show.  I still do not fully understand the
following, but it appears that the FrameLabel added by the Masked
function overrides the previous Text calls etc., completely the opposite
to the behaviour of Show.  The new Export command does give the same as

Display["c:\\temp\\tmp1.gif", gr2, "GIF"]

Display["c:\\temp\\tmp2.gif", Masked[gr2, RGBColor[1, 1, 1]], "GIF"]

Select[ToString[#] & /@ 
    Flatten[Masked[gr2, RGBColor[1, 1, 1]] /. Graphics -> List], 
  StringPosition[#, "Axis"] =!= {} &]

{"Text[X Axis, {0.5, -0.0202254}, {0., 1.}]",
 "Text[Y Axis, {-0.01875, 0.5}, {1., 0.}]",
 "FrameLabel -> {X Axis, Y Axis}"}

Thank you again!  This saved me much time.


  • Prev by Date: Re: HELP : Mathematica v4 producing erroneous results ! Mathematica3 worked fine...
  • Next by Date: need help.
  • Previous by thread: Re: Clippling of polygons within a defined region
  • Next by thread: RE: HELP : Mathematica v4 producing erroneous results ! Mathematica3 worked fine...