RE: Shadow a part of plot without affecting frame ticks .

• To: mathgroup at smc.vnet.net
• Subject: [mg33338] RE: [mg33318] Shadow a part of plot without affecting frame ticks .
• From: "Wolf, Hartmut" <Hartmut.Wolf at t-systems.com>
• Date: Sat, 16 Mar 2002 01:40:18 -0500 (EST)
• Sender: owner-wri-mathgroup at wolfram.com

```> -----Original Message-----
> From: jl_03824 at yahoo.com [mailto:jl_03824 at yahoo.com]
To: mathgroup at smc.vnet.net
> Sent: Friday, March 15, 2002 1:51 AM
> To: mathgroup at smc.vnet.net
> Subject: [mg33338] [mg33318] Shadow a part of plot without affecting
> frame ticks.
>
>
> I'll be very much appreciating if anybody would tell me how to shadow
> a part of figure but leave the frame tickmarks visible. I created a
> polygon (in light gray) of same shape and area as the region in the
> figure which I tend to shadow. It works well, but I also noticed that
> the frame tickmarks around are also shadowed. Could anybody tell me
> how to avoid shadowing the frame tickmarks. Thanks very much.
>
> Jun Lin
>

Jun Lin,

it is not clear what you tried, so a concrete example would have been most

Quite often one wants to have the *axes* not obscured by the Epilog. So if
you resorted to Frame -> True because of this problem, learn how to
circumvent that:

In[1]:= <<Geometry`Polytopes`

In[5]:=
p=ParametricPlot[
Evaluate[t{Cos[t+#],Sin[t+#]}&/@(2\[Pi]/5*Range[5]-1)], {t,0,\[Pi]},
Epilog -> {GrayLevel[.85], Polygon[Vertices[Pentagon]]},
AspectRatio -> Automatic]

If this were the plot you didn't like, you can bring the axes to front with
one or the other method I know of:

(1) take the FullGraphics

In[6]:= pp=FullGraphics[p]

In[7]:= Show[pp, AspectRatio -> Automatic]

(2) the package...

In[8]:= <<Graphics`FilledPlot`

..modifies Show as to understand the option AxesFront

In[12]:= Show[p, AxesFront->True]

If you want the frame in first place, then you'll get no problem if you
overlay the polygon with Show:

In[36]:= ppp = ParametricPlot[
Evaluate[t{Cos[t + #], Sin[t + #]} & /@ (2\[Pi]/5*Range[5])],
{t, 0, \[Pi]}, AspectRatio -> Automatic,
Axes -> False, Frame -> True]

In[38]:= Show[ppp,
Graphics[{GrayLevel[.85], Polygon[3 *
Join[1.2*{{0, 1}, {-1, 1}, {-1, -1}, {1, -1}, {1, 1}, {0, 1}},
Append[#, First[#]]& @(Reverse /@ Vertices[Pentagon])]
]}]]

You see how Show has expanded the frame to include all of the polygon!

However things are more problematic with Epilog, let's try

In[99]:=
ParametricPlot[
Evaluate[t{Cos[t + #], Sin[t + #]} & /@ (2\[Pi]/5*Range[5])], {t, 0,
\[Pi]},
AspectRatio -> Automatic, Axes -> False, Frame -> True,
Epilog -> {GrayLevel[.85], Polygon[3 *
Join[1.2*{{0, 1}, {-1, 1}, {-1, -1}, {1, -1}, {1, 1}, {0, 1}},
Append[#, First[#]]& @(Reverse /@ Vertices[Pentagon])]
]}, PlotRange -> All]

If we did not include the option PlotRange -> All, then part of the
surrounding polygon would have been clipped, and the graph will appear
awkwardly shifted. Anyway, the frame is covered by the polygon. Again...

In[100]:= Show[FullGraphics[%], AspectRatio -> Automatic]

In[101]:= Show[%%, AxesFront -> True]

...do their magic. But alas, the frame now is drawn with bounds such as if
the option PlotRange -> All were not effective. What helps is to
*explicitely* specify the PlotRange:

In[105]:=
ParametricPlot[
Evaluate[t{Cos[t + #], Sin[t + #]} & /@ (2\[Pi]/5*Range[5])], {t, 0,
\[Pi]},
AspectRatio -> Automatic, Axes -> False, Frame -> True,
Epilog -> {GrayLevel[.85],
Polygon[3 *
Join[1.2*{{0, 1}, {-1, 1}, {-1, -1}, {1, -1}, {1, 1}, {0, 1}},
Append[#, First[#]] &@(Reverse /@ Vertices[Pentagon])]
]}, PlotRange -> 3*1.2*{{-1, 1}, {-1, 1}}]

Still parts of the frame are missing, but both...

In[106]:= Show[FullGraphics[%], AspectRatio -> Automatic,
PlotRegion -> {{.05, .95}, {.05, .95}}]

In[107]:= Show[%%, AxesFront -> True]

...now are pretty (and the frame now is drawn around all of the polygon).
If I did not reduce the PlotRegion in Line 106, then still a small fraction
of the numbers below the frame would have been clipped.

Admittedly, all this took (me) more try and error than it should have.

--
Hartmut Wolf

___________
P.S. Having learnt all this, going back (in "regression") to better
understand, reveals this:

In[133]:=
ParametricPlot[
Evaluate[t{Cos[t + #], Sin[t + #]} & /@ (2\[Pi]/5*Range[5])], {t, 0,
\[Pi]},
AspectRatio -> Automatic, Axes -> False, Frame -> True,
Epilog -> {GrayLevel[.85],
Polygon[3 *
Join[1.2*{{0, 1}, {-1, 1}, {-1, -1}, {1, -1}, {1, 1}, {0, 1}},
Append[#, First[#]] &@(Reverse /@ Vertices[Pentagon])]
]}, PlotRange -> 1.03*3*1.2*{{-1, 1}, {-1, 1}} ];
^^^^

So if you manually specify the PlotRange *a little bit larger* than it is
needed, then ParametricPlot (in my demonstration) works without further
tricks of FullGraphics, package FilledPlot and option AxesFront.

```