Re: !p.multi and tv [message #11676] |
Mon, 18 May 1998 00:00  |
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
____________________________________________________________ ______________
|
|
|