[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: !P.MULTI + POSITION keyword problem

Grant W. Petty (gpetty@rain.atms.purdue.edu) writes:
> I just learned about the !P.MULTI variable and wanted to use it to put
> multiple panels on a single postscript page.  The problem (I
> discovered after much head scratching) is that each of my panels use
> 'tv' and 'plot' calls which require the POSITION keyword for alignment
> (like David's 'imagebar' example in his book and for similar reasons).
> Unfortunately, the POSITION keyword causes IDL to disregard the
> contents of !P.MULTI (except for the first element).  I had hoped that
> POSITION would be defined in terms of "virtual" Normalized Device
> Coordinates for the current panel indicated by !P.MULTI, but this is
> apparently not the case.  Is there a simple way to get the desired
> effect without having to manually calculate new POSITION coordinates for
> each panel?

A "simple" way!? No, probably not. There was a fairly extensive
discussion in this news group about !P.Multi and the TV command 
started by an article by Cathy (csaute3@alumni.umbc.edu) on 
28 May 1998. The basic problem is that the TV command doesn't
"advance" the !P.Multi variable, nor can you figure out where
to put the image until *after* something has been plotted in
the window. 

Sometimes this is not a problem because you can write the 
program in such a way as to get a PLOT command (or something
else) to fulfill this essential role.

I offered this simple program as an example that could
position an image with axes around it in a window that
is set up with !P.Multi.

The program works like this. First, set up !P.Multi.

   IDL> !P.Multi=[0, 3, 2]

Then, pass this information to the program:

   IDL> MultiImages, !P.Multi

Works great in this limited capacity. :-)



PRO MultiImages, multi
IF N_Params() NE 1 THEN multi = [0, 2, 2]
imageFile = Filepath(SubDir=['examples','data'], 'worldelv.dat')
image = BytArr(360, 360)
OpenR, lun, imageFile, /Get_LUN
ReadU, lun, image
Free_Lun, lun
Window, XSize=500, YSize=400
!P.Multi = multi
FOR j=0, multi[1]*multi[2]-1 DO BEGIN
    Plot, Findgen(11), Color=!P.Background
    x1 = !X.Region[0] + 0.05
    x2 = !X.Region[1] - 0.05
    y1 = !Y.Region[0] + 0.05
    y2 = !Y.Region[1] - 0.05
    TVImage, image, Position=[x1, y1, x2, y2]
    Plot, Findgen(11), position=[x1, y1, x2, y2], xticklen=-0.02, $
      yticklen=-0.02, xtitle='latitude', ytitle='longitude', $
      /nodata, /noerase

David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155

[Note: This follow-up was e-mailed to the cited author.]