plotdev='x'
plotdev='ps'

set_plot,plotdev
IF plotdev eq 'x' THEN  device,retain=2,pseudo=8
IF plotdev eq 'x' THEN  erase
IF plotdev eq 'ps' THEN device,/color,file='planewave.ps'

;make a color table

     r= [  0,255,255,  0,  0,  0]
     g= [  0,  0,255,255,  0,  0] 
     b= [  0,  0,  0,255,255,  0]
     tvlct,r,g,b


npts= 410
axis=findgen(npts+1)/npts
sinewave=sin(axis*6.8*!pi)
zero=fltarr(npts+1)

min_axis= axis(0) & max_axis= axis(npts)
min_sinewave= -1. & max_sinewave= 1.
min_zero= -1. & max_zero= 1.

!x.s= [-min_axis, 1.]/(max_axis - min_axis)
!y.s= [-min_sinewave, 1.]/(max_sinewave - min_sinewave)
!z.s= [-min_zero, 1.]/(max_zero - min_zero)

t3d,/reset,rot=[0,-50,-10],trans=[1.,.2,0.] ,scale=.6*[1,1,1], pers=5.
plots,axis,sinewave,zero,/t3d,/data, thick=3.5,color= 3, linestyle=2

plots,axis,zero,zero,/t3d,/data, thick=1

arrow_x= [0., 1., .8, .8, 1., .8, .8, 1.]
arrow_y= [0., 0., .1, -.1, 0., .05, -.05, 0.]
arrow_z= fltarr(8)

for index= 0, npts, 10 do begin &$
   arrow_e_x=arrow_z+axis(index) &$
   arrow_e_y=arrow_x*sinewave(index) &$
   arrow_e_z=arrow_y*.25 &$
   plots,arrow_e_x, arrow_e_y, arrow_e_z, /t3d,/data, thick=2, color= 4
endfor

arrow_ax_x= 1.02 + arrow_x*.1
arrow_ax_y= 0.00 + arrow_y*.1
arrow_ax_z= arrow_z
plots,arrow_ax_x, arrow_ax_y, arrow_ax_z,/t3d,/data
xyouts, arrow_ax_x(0),arrow_ax_y(0)+.03, z=arrow_ax_z(0), $
   'Direction of', /t3d, /data
xyouts, arrow_ax_x(0),arrow_ax_y(0)-.06, z=arrow_ax_z(0), 'travel',/t3d,/data

xyouts, 0.3, 0.7,  'A Plane Wave', Size=2
xyouts, .7,-.4,'Field vector as',size=.7
xyouts, .7,-.45,'a function of time',size=.7
xyouts, .7,-.5,'or position', Size=.7


IF plotdev EQ 'ps' THEN device,/close 

END
