MathGroup Archive 2007

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

Search the Archive

Re: Overlaying a grid on graphics to guide placement

  • To: mathgroup at smc.vnet.net
  • Subject: [mg73807] [mg73807] Re: [mg73785] Overlaying a grid on graphics to guide placement
  • From: "Michael A. Gilchrist" <mikeg at utk.edu>
  • Date: Fri, 2 Mar 2007 06:02:21 -0500 (EST)
  • References: <5271946.1172665925066.JavaMail.root@eastrmwml10>

Hi Bob,

Thanks for the suggestion, that helps with the single non-log plots.

But what I'm really after is a grid that is displayed OVER the entire set 
of figures in a Show function (or DisplayTogether).  I often need to put a 
label such as (a) or (b) in the upper left hand corner each subplots. As 
far as I know, the best way to do that is by adding Text[] commands in the 
epilog of the final Show[] or Display[] command.




On Wed, 28 Feb 2007, Bob Hanlon wrote:

> You could use the GridLines option.
>
> Needs["Graphics`"];
>
> SetOptions[#,PlotStyle->Red,Frame->True,Axes->False,
>        PlotRange->{Automatic,{0.95,3.05}}]&/@
>    {Plot,LogLogPlot,LogLinearPlot};
>
> DisplayTogetherArray[{
>      {LogLogPlot[Exp[-x+1],{x,0,1},
>          GridLines->Automatic],
>        LogLogPlot[Exp[-x+1],{x,0,1},
>          GridLines->{Table[10^-n,{n,0,5}],
>              Table[y,{y,1,3,.5}]}]},
>      {LogLinearPlot[Exp[-x+1],{x,0,1},
>          GridLines->Automatic],
>        LogLinearPlot[Exp[-x+1],{x,0,1},
>          GridLines->{Table[10^-n,{n,0,5}],Automatic}]},
>      {Plot[Exp[-x+1],{x,0,1},
>          GridLines->Automatic]}},
>    ImageSize->800];
>
>
> Bob Hanlon
>
> ---- "Michael A. Gilchrist" <mikeg at utk.edu> wrote:
>> Hi,
>>
>> I'd like to develop a function which overlays a grid on a graphics such as
>> a plot to help with the placement of additional graphics object through
>> things like Epilog or Prolog.
>>
>> I've taken a stab at it below,
>>
>> (*construction of grid*)
>> imax = jmax = 4;
>> step = 0.25;
>>
>> hlines =
>>      Table[{If[j == 0., Black, LightGray],
>>          Line[{{-imax, j}, {imax, j}}]}, {j, -jmax, jmax, step}];
>>
>> vlines =
>>      Table[{If[j == 0., Black, LightGray],
>>          Line[{{ j, -imax}, {j, imax}}]}, {j, -jmax, jmax, step}];
>>
>> hlabels = Table[Text[j, {j, 0}, {1, 1.1}], {j, -jmax, jmax, 1}];
>> vlabels = Table[Text[j, {0, j}, {1.1, 1}], {j, -jmax, jmax, 1}];
>>
>> grid = Join[hlines, vlines, hlabels, vlabels];
>>
>> (* ooh it looks good on its own*)
>> Show[Graphics[grid]]
>>
>>
>> (*not so good here*)
>> LogLogPlot[Exp[-x + 1], {x, 0, 1},
>>    Epilog -> grid]
>>
>> Plot[Exp[-x + 1], {x, 0, 1},
>>    Epilog -> grid]
>>
>> Show[GraphicsArray[{
>>        {LogLogPlot[Exp[-x + 1], {x, 0, 1},
>>            DisplayFunction -> Identity]},
>>        {Plot[Exp[-x + 1], {x, 0, 1},
>>            DisplayFunction -> Identity]}}], Epilog -> grid]
>>
>>
>> If you run these commands you'll see that my attempt is inelegant and it
>> doesn't work very well.  Ideally, the grid would (a) adjust itself so that
>> its boundaries are within the graphics object and (b) adjust the spacing
>> and labeling so that the grid lines are frequent enough to be informative
>> but not obscure the entire figure.
>>
>> If any one has any suggestions I'd greatly appreciate hearing them.
>>
>> Thanks in advance.
>>
>> Mike
>>
>> -----------------------------------------------------
>> Department of Ecology & Evolutionary Biology
>> 569 Dabney Hall
>> University of Tennessee
>> Knoxville, TN 37996-1610
>>
>> phone:(865) 974-6453
>> fax:  (865) 974-6042
>>
>> web: http://eeb.bio.utk.edu/gilchrist.asp
>
>

-----------------------------------------------------
Department of Ecology & Evolutionary Biology
569 Dabney Hall
University of Tennessee
Knoxville, TN 37996-1610

phone:(865) 974-6453
fax:  (865) 974-6042

web: http://eeb.bio.utk.edu/gilchrist.asp
-----------------------------------------------------



  • Prev by Date: Re: monomials in Graded Lexicographic Order and associated
  • Next by Date: Re: Overlaying a grid on graphics to guide placement
  • Previous by thread: Re: Overlaying a grid on graphics to guide placement
  • Next by thread: Re: Overlaying a grid on graphics to guide placement