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

Home » Public Forums » archive » multiplot solution
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
multiplot solution [message #3074] Fri, 04 November 1994 13:50
meo is currently offline  meo
Messages: 6
Registered: November 1994
Junior Member
Hi this is fern. I wrote a program a year ago to plot many graphs on top
of eachother (with no spaces or titles between them) :

PRO MultiPlot,DataArray,YStringArray,XString,MainString,XArray,Y LRange, $
YURange,NOWINDOW=NOWINDOW,NOEQUAL=NOEQUAL
;+
;*********************************************************** ************;
; PRO MultiPlot,DataArray,YStringArray,XString,MainString,XArray ;
; YLRange, YURange,NOWINDOW=NOWINDOW,NOEQUAL=NOEQUAL ;
;*********************************************************** ************;
; Author: Fernando Meo ;
; Date: March31, 1993 ;
; Purpose: Displays multiple data graphs in one window ;
; ;
; Method: The main body of the routine was borrowed from Jamie ;
; Gunn. ;
; ;
; Variables: ;
; inputs: DataArray : Two dimentional array ;
; containing the data to ;
; be displayed. Each row ;
; REPRESENTS A PLOT. ;
; YStringArray : Array of y-title for ;
; each plot. ;
; XString : String for xtitle. ;
; MainString : Main Title ;
; XArray @ : Arrays representing ;
; the x axis values. If ;
; it is inputted as an ;
; integer or not inputted ;
; at all, the values will ;
; be generated as indicies;
; YURange @ : Y axis upper limit range;
; YLRange @ : Y axis lower limit range;
; NOEQUAL @ : Unequal y-axis (max) ;
; outputs: none ;
; input/output: none ;
; keywords: NOWINDOW : Supress the creation of window;
; ;
;*********************************************************** ************;
;-
ON_ERROR,1
Info = SIZE(DataArray)
Num = N_ELEMENTS(YStringArray)
;***** Make sure that the dimentions are equal
IF Info(2) NE Num THEN BEGIN
PRINT,'********** DIMENSIONS ARE NOT COMPATABLE **********'
RETURN
ENDIF

IF KEYWORD_SET(NOWINDOW) EQ 0 THEN CreateWin,22,MainString,600,400

N = Num

;***** Generate the X axis values if applicable
IF N_ELEMENTS(XArray) LE 1 THEN XArray = INDGEN(Info(1))

;***** Generate the Yrange
IF N_ELEMENTS(YURange) EQ 0 THEN YURange = MAX(DataArray)
IF YURange LT 0 THEN YURange = MAX(DataArray)
IF N_ELEMENTS(YLRange) EQ 0 THEN YLRange = MIN(DataArray)
IF YLRange LT 0 THEN YLRange = MAX(DataArray)


N2=fix((N+1)/2)
;***** N=# of graphs

CASE N OF
1:!p.multi=0
2:!p.multi=[0,1,2]
ELSE:BEGIN
!p.multi=[0,2,N2+1,0,1] ; 2 columns
!y.margin=[0,0]
ENDELSE
ENDCASE

!x.tickname=' ' ;Suppress x-axis labelling

;***** Plot the Data!!!!

FOR i=0,N-1 DO BEGIN
t = 1
IF (i eq N2-1) or (i eq N-1) THEN BEGIN
;***** The end of the column
!x.tickname=''
XAxisTitle = XString
ENDIF ELSE BEGIN
!x.tickname=' '
XAxisTitle = ''
ENDELSE

IF (i eq N2) and (N gt 2) THEN !p.multi(0)=N2+1

IF (total(t) EQ 0) THEN BEGIN
!p.multi(0)=!p.multi(0)-1 ;avoid trying to plot empty signals
ENDIF ELSE BEGIN
IF KEYWORD_SET(NOEQUAL) EQ 0 THEN BEGIN
PLOT,XArray,DataArray(0:*,i),YTITLE=YStringArray(i),$
YRANGE=[YLRange,YURange],xtitle=XAxisTitle,YSTYLE=1,XSTYLE=1
oplot,[0,500],[0,0]
ENDIF ELSE BEGIN
PLOT,XArray,DataArray(0:*,i),YTITLE=YStringArray(i),$
xtitle=XAxisTitle,YSTYLE=1,XSTYLE=1
oplot,[0,500],[0,0]

ENDELSE

ENDELSE
ENDFOR

!x.margin=[10,3]
!y.margin=[4,2] ;Back to normal

xyouts,.1,.06,MainString,/normal
!p.multi=0
!x.tickname=''


RETURN
END


Try it out. BY THE WAY, THE PROCEDURE "CreateWin" should be replaced by
the command "Window,1". The "CreateWin" procedure is a procedure that
I created.

Good Luck!

CIAO
Fern...
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Resetting a DRAW widget to have new size/scroll area...?
Next Topic: Re: Need ideas for a data structure

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

Current Time: Fri Oct 10 10:17:40 PDT 2025

Total time taken to generate the page: 1.43974 seconds