; this was originally "makefig5c" to make Fig. 4 of Weeks & Weitz
; PRL (2002).  There was some prior version of this paper for
; which we had five figures.  Nowadays I would not name my
; mkfigure files with a figure number but rather a descriptor
; of what I'm plotting.  Although of course these are example
; files so indeed I have used numbers for them, like this is
; fig03.  :-)


filename='~/fig03'
sp,1
device,file=filename+'.eps'
device,/color
loadct,76,file='~weeks/ericcol.tbl'
pfontold=!P.FONT
!P.FONT=1
device,set_font='Times',/tt_font

; these are just some colors Eric likes:
col6=21; reddish purple
col5=42; red
col4=160; green
col3=187; light blue/green
col2=216; dark blue
col1=255; dark purple

; sometimes when I have a figure with multiple stacked panels, I
; only want the x-axis to have numbers for the bottom panel.
; Therefore I use xtickname=bb to define all the names of the
; x-ticks to be blanks.  Thus the next two lines:
b=" "
bb=[b,b,b,b,b,b,b]

; ===============================BEGIN PLOTTING BELOW

y1=0.17 & dy=0.70 & y2=y1+dy-0.02 & x1=0.10 & x2=0.42 & dy2=0.08
css=2 & ddx = 0.02 & ddy=dy-0.09 & ddd=2.3
dx=0.44
ytl=0.05

; part (a): 
t0=total(res0(1,wsin)/sine(wsin))*(res0(0,wsin(1))-res0(0,wsin(0)))/3.14159
t00=total(res00(1,wsin00)/sine00(wsin00))*(res00(0,wsin00(1))- $
      res00(0,wsin00(0)))/3.14159
t00=t00*3.14159265 ; added June 28, 2001 !!
t000=total(res000(1,wsin000)/sine000(wsin000))*(res000(0,wsin000(1))- $
      res000(0,wsin000(0)))/3.14159
plot,res0(0,wsin)/3.14159265,smooth(res0(1,wsin)/sine(wsin)/t0,3), $
	xr=[0,1],pos=[x1,y1,x2,y2],yticks=3, $
    chars=css,xtitle="!9q!7 (rad)",/xs, $
	xtickname=['!70','!9p!7/3','2!9p!7/3','!9p!7'],xticks=3, $
	yrange=[0,0.75],/ys,/nodata,yminor=5,yticklen=ytl
pii=3.14159265
nw=n_elements(wsin00)-2
oplot,res00(0,wsin00(0:nw))/pii,  $
   smooth(res00(1,wsin00(0:nw))/sine00(wsin00(0:nw))/t00,3)
;oplot,res000(0,wsin000)/pii,smooth(res000(1,wsin000)/sine000(wsin000)/t000,7)
xyouts,x1+ddx,y1+ddy,"!7(a)",chars=ddd,/normal
xyouts,-0.25,0.75/2,/data,align=0.5,chars=css,orientation=90, $
    "!8P!7(!9q,f!7)"

; this is the panel (b) inset P(dR12|R12)
ox=0.14 & oy=0.495
nx=ox+0.025 & ny=oy+0.025
css2=css*0.8
plot,res2(0,*),res2(1,*)/t2/dr2,xr=[-0.4,0.4],  $
    pos=[x1+dx+ox,y1+oy,x2+dx+ox-nx,y2+oy-ny], $
    chars=css2,/xs,/noerase, $
;;	xtitle="!9D!8R!D12!N (!9m!7m)"
    yticks=4,ytickname=[" "," "," "," "," "], $
;;	xtickname=[' ','-0.3',' ',' ','0.0',' ',' ','0.3',' '], $
	xtickname=[' ',' ',' ',' ',' ',' ',' ',' ',' '], $
    xticks=8,xticklen=0.05,yticklen=0.04,yminor=2
oplot,res3(0,*),res3(1,*)/t3/dr3,l=2
; xyouts,x1+ddx,y1+dy*1+ddy,"!7(b)",chars=ddd,/normal
xyouts,-0.5,4,/data,align=0.5,chars=css2,orientation=90, $
    "!8P!7(!9D!8R!D12!N!7)"
eee=-2.0
xyouts,-0.3,eee,'-0.3',/data,chars=css2,align=0.5
xyouts,0.0,eee,'0.0',/data,chars=css2,align=0.5
xyouts,+0.3,eee,'0.3',/data,chars=css2,align=0.5
xyouts,0.0,eee*2,"!9D!8R!D12!N (!9m!7m)",/data,chars=css2,align=0.5

; panel (b) -- sigma_R12:
plot,av(0,5:*),av(2,5:*),xr=[2,6],pos=[x1+dx,y1,x2+dx,y2],chars=css, $
    /noerase,xtickname=[" "," "," "," "," "],  xminor=2, $
    yrange=[0.00,0.275],/ys,yticks=1,ytickname=[" "," "],l=2,yticklen=ytl
xyouts,x1+dx+ddx,y1+ddy,"!7(b)",chars=ddd,/normal
; label the right hand vertical axis by hand:
px=6.1 & py=-0.005
xyouts,px,py+0.005,'!70.0',chars=css
xyouts,px,py+0.10,'0.1',chars=css
xyouts,px,py+0.20,'0.2',chars=css
xyouts,6.9,0.17,"!9s!8!DR!D12!N!7 (!9m!7m!N!7)",orientation=-90,chars=css


; part (b) -- g(r):
; Note I am just plotting a second graph in the same location
; as I previously plotted the sigma graph.
plot,gr(0,*),gr(1,*),xr=[2,6],pos=[x1+dx,y1,x2+dx,y2],chars=css, $
    /noerase,xtitle="!8R!D12!N !7(!9m!7m!N!7)",yticks=2, $
	yminor=2,yrange=[0,5.5],/ys,ytickv=[0,2,4],xminor=2,yticklen=ytl
arrow,3.9,1,3.2,1,/data
arrow,3.9,2.8,4.6,2.8,/data
xyouts,1.5,5.5/2,/data,align=0.5,chars=css,orientation=90, $
    "!8g!8(R!D12!N!8)!7"


; ===============================END PLOTTING ABOVE

!P.FONT=pfontold

device,/close
sp,3

spawn,'~weeks/bin/bbox_add.pl '+filename+'.eps'
spawn,'~weeks/bin/pagebbox.sh '+filename+'.eps'

; next few lines are to make a JPEG file in case you want to use
; it in powerpoint.  You can change -xsize=900 to change the
; resolution of the JPEG.
spawn,'pstopnm -portrait -stdout -xsize=900 '+filename $
   +'.eps > blah.ppm'
spawn,'pnmtojpeg -quality=95 blah.ppm > '+filename+'.jpg'
spawn,'rm blah.ppm'
cropjpg,filename+'.jpg'

; load in the JPEG and display it, just for fun:
read_jpeg,filename+'.jpg',tmp

; this is to shrink the image, if needed
tmp1=small(reform(tmp(0,*,*)))
nx=n_elements(tmp1(*,0))
ny=n_elements(tmp1(0,*))
tmp4=bytarr(3,nx,ny)
tmp4(0,*,*)=tmp1
tmp4(1,*,*)=small(reform(tmp(1,*,*)))
tmp4(2,*,*)=small(reform(tmp(2,*,*)))

erase
tv,tmp,true=1    ; fullsize image
;tv,tmp4,true=1   ; halfsize image


