MathGroup Archive 1999

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

Search the Archive

Re: Clippling of polygons within a defined region

  • To: mathgroup at smc.vnet.net
  • Subject: [mg19080] Re: Clippling of polygons within a defined region
  • From: John Tanner <john at janacek.demon.co.uk>
  • Date: Thu, 5 Aug 1999 01:35:02 -0400
  • Organization: Peace with the World
  • References: <7nrf6u$ie2@smc.vnet.net> <7o5ff4$rgt@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

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

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
nothing!).

*************example********************
In[1]:=
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]]

In[2]:=
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"]

In[3]:=
Masked[gr2, RGBColor[1, 1, 1]]

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

Out[4]=
{"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
Show.

****************************************
In[5]:=
Display["c:\\temp\\tmp1.gif", gr2, "GIF"]

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

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

Out[7]=
{"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.

John.



  • 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...