comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: !p.multi and tv
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: !p.multi and tv [message #11676] Mon, 18 May 1998 00:00 Go to next message
pit is currently offline  pit
Messages: 92
Registered: January 1996
Member
In article <6ji0he$n3v$1@nnrp1.dejanews.com>,
csaute3@alumni.umbc.edu writes:
> davidf@dfanning.com (David Fanning) wrote:
>
>> You might want to try TVImage on my webpage.
>
>
> I would like to use !P.MULTI and TV to position images like you
> would plots. For plots I can do the following to get a column of
> 4 plots. I have not specified any positioning coordinates. !p.multi
> "handles" that for me.

I have one that respects the setting of !p.multi - maybe try it out.

Peter

---------------------------
PRO Tvimg, image, xax, yax, position=pos, box=box, noerase=noerase, $
nolabels=nolabels, noscale=noscale, ASPECT=aspect, _EXTRA=extra

;+
; NAME:
; TVIMG
; PURPOSE:
; Display an image in an window with border and axis
; CALLING SEQUENCE:
; TVIMG, IMAGE [, XAX [, YAX] [, KEYWORDS]]
; INPUTS:
; IMAGE : Image to display
; OPTIONAL INPUT PARAMETER:
; XAX : (input) Xaxis values
; YAX : (input) Yaxis values
; KEYWORDS:
; POSITION: Position of Plot area corners in norm coordinates.
; Standard graphics keywords
; BOX : (input) Draw the koordinate axes with linethick
; BOX. Makes the plot look a bit Displa-Style.
; ASPECT : (Flag) Keep aspect ratio of the image
; NOERASE : (Flag) Don't clear plot window before drawing
; NOLABELS: (Flag) Don't draw axis annotations
; NOSCALE : (Flag) By default, TVSCL is used to display the
; image. Set this keyword to use TV instead. Remember
; to do bytescaling yourself!
; Additionally, all valid keywords for the plot routine are
; allowed.
; RESTRICTIONS:
;
; PROCEDURE:
; Eventualy rescale the image to fit the display, then oplot an
; empty co-ordinate system. Draw thick bounding box if required.
; MODIFICATION HISTORY:
; 24-Sep-1994 P.Suetterlin, KIS
; 23-Feb-1995 Correct handling of multiple-plot styles (!P.style<>0)
; 25-Jul-1996 Use Keyword _EXTRA to pass keywords to plot
; routine.
; 29-Oct-1997 Add keyword ASPECT to preserve the aspect ratio of
; the image
;-

on_error, 2

IF n_params() LT 1 THEN $
message, 'Syntax: TVIMG, Image [, xax, yax]'

s = size(image)
sx = s(1) & sy = s(2)

IF n_params() LT 3 THEN $
yax = indgen(sy)

IF n_params() LT 2 THEN $
xax = indgen(sx)

;;;
;;; We do an empty plot to
;;; 1) clear the screen (except NOERASE is set)
;;; 2) Set !x.window and !y.window if it is a multiple plot
;;;

plot, [0, 1], /nodata, xsty = 4, ysty = 4, xtit = '', ytit = '', $
subtit = '', tit = '', noerase=noerase

IF NOT keyword_set(pos) THEN BEGIN
IF (!X.window(1)-!X.window(0)) EQ 0 THEN $
pos = [0.1, 0.1, 0.95, 0.95] $
ELSE $
pos = [!X.window(0), !Y.window(0), !X.window(1), !Y.window(1)]
ENDIF

IF keyword_set(aspect) THEN BEGIN
;;; current aspect ratio
asp = float(sx)/sy
;;; aspect ratio of the plot area
asp1 = (pos(2)-pos(0))*!d.x_size/((pos(3)-pos(1))*!d.y_size)
IF asp LT asp1 THEN BEGIN
;;; area is broader than pic -> shrink area horizontaly
nw = asp/asp1*(pos(2)-pos(0))
pos(0) = pos(0)+((pos(2)-pos(0))-nw)/2
pos(2) = pos(0)+nw
ENDIF ELSE BEGIN
;;; area is higher than pic -> shrink area vertically
nw = asp1/asp*(pos(3)-pos(1))
pos(1) = pos(1)+((pos(3)-pos(1))-nw)/2
pos(3) = pos(1)+nw
ENDELSE
ENDIF

IF !D.name NE 'PS' THEN GOTO, x

IF keyword_set(noscale) THEN BEGIN
tv, image, pos(0), pos(1), xsize=pos(2)-pos(0), $
ysize=pos(3)-pos(1), /norm
ENDIF ELSE BEGIN
tvscl, image, pos(0), pos(1), xsize=pos(2)-pos(0), $
ysize=pos(3)-pos(1), /norm
ENDELSE

plot, xax([0, sx-1]), yax([0, sy-1]), /nodata, /noerase, pos=pos, $
/xsty, /ysty, xtickname=replicate(' ', 15), ytickname=replicate(' ', 15), $
_EXTRA=extra

IF NOT keyword_set(nolabels) THEN BEGIN
axis, xax=0, /xsty
axis, yax=0, /ysty
ENDIF

IF keyword_set(box) THEN BEGIN
lu = [!X.crange(0), !Y.crange(0)]
ro = [!X.crange(1), !Y.crange(1)]
plots, [lu(0), ro(0), ro(0), lu(0), lu(0)], $
[lu(1), lu(1), ro(1), ro(1), lu(1)], thick = box
ENDIF


return

X:
nx = fix((pos(2)-pos(0))*!D.x_size+0.5)+1
ny = fix((pos(3)-pos(1))*!D.y_size+0.5)+1

IF keyword_set(noscale) THEN $
tv, rescale(image, nx, ny), pos(0), pos(1), /norm $
ELSE $
tvscl, rescale(image, nx, ny), pos(0), pos(1), /norm

plot, xax([0, sx-1]), yax([0, sy-1]), /nodata, /noerase, pos=pos, $
/xsty, /ysty, xtickname=replicate(' ', 15), ytickname=replicate(' ', 15), $
_EXTRA=extra

IF NOT keyword_set(nolabels) THEN BEGIN
axis, xax=0, /xsty
axis, yax=0, /ysty
ENDIF

IF keyword_set(box) THEN BEGIN
lu = [!X.crange(0), !Y.crange(0)]
ro = [!X.crange(1), !Y.crange(1)]
plots, [lu(0), ro(0), ro(0), lu(0), lu(0)], $
[lu(1), lu(1), ro(1), ro(1), lu(1)], thick = box
ENDIF

END


--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~
Peter "Pit" Suetterlin http://www.uni-sw.gwdg.de/~pit
Universitaets-Sternwarte Goettingen
Tel.: +49 551 39-5048 pit@uni-sw.gwdg.de
-- * -- * ...-- * -- * ...-- * -- * ...-- * -- * ...-- * -- * ...-- * --
Come and see the stars! http://www.kis.uni-freiburg.de/~ps/SFB
Sternfreunde Breisgau e.V. Tel.: +49 7641 3492
____________________________________________________________ ______________
Re: !p.multi and tv [message #11733 is a reply to message #11676] Sat, 16 May 1998 00:00 Go to previous messageGo to next message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
Craig Markwardt <craigmnet@astrog.physics.wisc.edu> writes:
> I have just updated my web page with some more programs.

Sorry, the web page is
http://astrog.physics.wisc.edu/~craigm/idl/idl.html

Craig

--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@astrog.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
Re: !p.multi and tv [message #11735 is a reply to message #11733] Sat, 16 May 1998 00:00 Go to previous messageGo to next message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
csaute3@alumni.umbc.edu writes:
>
> I would like to use !P.MULTI and TV to position images like you
> would plots. However I'm having difficulty and all of images
> are in the corner of the window. Help!
>
> Cathy

Hi--

I have just updated my web page with some more programs. One is an
image "plotting" program which I find *very* useful. PLOTIMAGE, among
other things, should respect the !p.multi setting. Check under
"plotting programs". Each file has extensive documentation in the
header -- my hands are tired from typing them!

Caveats:
* you will need to download a few other programs, also listed there
* you will need TVIMAGE from David Fanning's web page
(here: http://www.dfanning.com/documents/programs.html)

If you tell PLOTIMAGE the physical units of your image, then you can
crop the image by simply giving a larger or smaller XRANGE/YRANGE.

Good luck,
Craig


--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@astrog.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
Re: !p.multi and tv [message #11743 is a reply to message #11733] Fri, 15 May 1998 00:00 Go to previous messageGo to next message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Cathy (csaute3@alumni.umbc.edu) writes:

> I would like to use !P.MULTI and TV to position images like you
> would plots.

> IDL> window, 0
> IDL> !p.multi = [0,1,4,0,0]
> IDL> plot, indgen(10)
> IDL> plot, indgen(20)
> IDL> plot, indgen(30)
> IDL> plot, indgen(40)
>
> tvimage.pro is not capable of positioning 4 images on the page like
> this. Is there something else that has this capability?
>
> Or is there a way to determine the position values that !p.multi
> "determines for you", and then use these with tvimage.pro?

I can see that "IDL doesn't work like this" won't satisfy
you. How about something like this:

************************************************************ ****
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 ; A hack, unfortunately. :-(
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]
ENDFOR
END
************************************************************ ******

If you want the images in, for example, a 3-by-2 arrangement,
you can type this:

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

I'll leave it as an exercise for the reader to figure out
how to get the images into the program. (Here is a hint:
I would use an array of pointers.)

Cheers,

David
-----------------------------------------------------------
David Fanning, Ph.D.
Fanning Software Consulting
E-Mail: davidf@dfanning.com
Phone: 970-221-0438
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: !p.multi and tv [message #11746 is a reply to message #11743] Fri, 15 May 1998 00:00 Go to previous messageGo to next message
csaute3 is currently offline  csaute3
Messages: 10
Registered: March 1998
Junior Member
davidf@dfanning.com (David Fanning) wrote:

> You might want to try TVImage on my webpage.


I would like to use !P.MULTI and TV to position images like you
would plots. For plots I can do the following to get a column of
4 plots. I have not specified any positioning coordinates. !p.multi
"handles" that for me.

IDL> window, 0
IDL> !p.multi = [0,1,4,0,0]
IDL> plot, indgen(10)
IDL> plot, indgen(20)
IDL> plot, indgen(30)
IDL> plot, indgen(40)

tvimage.pro is not capable of positioning 4 images on the page like
this. Is there something else that has this capability?

Or is there a way to determine the position values that !p.multi
"determines for you", and then use these with tvimage.pro?

Cathy

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
Re: !p.multi and tv [message #11861 is a reply to message #11676] Thu, 28 May 1998 00:00 Go to previous message
csaute3 is currently offline  csaute3
Messages: 10
Registered: March 1998
Junior Member
In article <6jp3cl$jus$3@gwdu19.gwdg.de>,
pit@uni-sw.gwdg.de wrote:
>
> In article <6ji0he$n3v$1@nnrp1.dejanews.com>,
> csaute3@alumni.umbc.edu writes:
>>
>> I would like to use !P.MULTI and TV to position images like you
>> would plots. For plots I can do the following to get a column of
>> 4 plots. I have not specified any positioning coordinates. !p.multi
>> "handles" that for me.
>
> I have one that respects the setting of !p.multi - maybe try it out.
>
> PRO Tvimg, image, xax, yax, position=pos, box=box, noerase=noerase, $
> nolabels=nolabels, noscale=noscale, ASPECT=aspect, _EXTRA=extra
[...]

Tvimg.pro uses a function called "rescale". This is not an IDL function.
Is this a routine that you wrote?

Cathy

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: accessing Siemens magnetom MR images
Next Topic: Re: PostScript and IDL,

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 18:39:22 PDT 2025

Total time taken to generate the page: 0.00725 seconds