
;+
;   This tests your ability to put multiple panels into a plot window
;   while making best use of the space in the window. Specifically,
;   how to work with the POSITION keyword.
;
;   Ver.1, 1-May-2019, Peter Young
;-

x=findgen(101)/100.*2.*!pi

;
; Keywords that are common to all the plots.
;
th=2
extra={thick: th, xthick: th, ythick: th, xticklen: 0.015,yticklen: 0.015,xstyle: 1, $
       font_size: 14, xminor: 1, $
       xtitle: 'X-axis', ytitle: 'Y-axis'}


;
; Create the window that will contain the individual panels.
;
w=window(dim=[1000,800])

;
; First define three equal width columns (dx) with separations between
; the plots (ddx) that give room for the Y-axis labels.
;
x0=0.00
x1=0.99
dx=(x1-x0)/3.
ddx=0.09

;
; Define lower and upper boundaries in Y
;
y0=0.00
y1=0.98

;
; Do single plot in first column.
;
ddy=0.08   ; gap for X-axis label
p=plot(/current,x,sin(x),pos=[x0+ddx,y0+ddy,x0+dx,y1], $
       _extra=extra)


;
; Put two plots in the second column
;
dy=(y1-y0)/2.
p1=plot(/current,x,sin(x),pos=[x0+dx+ddx,y0+ddy,x0+2*dx,y0+dy], $
       _extra=extra)
p2=plot(/current,x,sin(x),pos=[x0+dx+ddx,y0+dy+ddy,x0+2*dx,y0+2*dy], $
       _extra=extra)

;
; Put three plots in the 3rd column
;
dy=(y1-y0)/3.
q1=plot(/current,x,sin(x),pos=[x0+2*dx+ddx,y0+ddy,x0+3*dx,y0+dy], $
       _extra=extra)
q2=plot(/current,x,sin(x),pos=[x0+2*dx+ddx,y0+dy+ddy,x0+3*dx,y0+2*dy], $
       _extra=extra)
q3=plot(/current,x,sin(x),pos=[x0+2*dx+ddx,y0+2*dy+ddy,x0+3*dx,y0+3*dy], $
        _extra=extra)

;
; Now add labels - note trick for getting letters
;
objlist=[p,p1,p2,q1,q2,q3]
FOR i=0,5 DO BEGIN
  lett=string(byte(i+97))
  t=text(/data,target=objlist[i],0.5,-0.9,'('+lett+')',font_size=fs)
ENDFOR 

w.save,'exercise4.png',resolution=144

END
