load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
begin
NPTS = 200
PI100 = 0.031415926535898
EXP = 2.7182818
NPLOTS = 4
;
; Create data for the four XY plots.
;
theta1 = PI100*ispan(0,NPTS-1,1)
theta2 = theta1+10.5
y = new((/NPLOTS,NPTS/),float)
y(0,:) = sin(theta1)
y(1,:) = sin(theta1 * theta1)
y(2,:) = sin(2*sqrt(fabs(theta1)))
y(3,:) = sin(3*sqrt(fabs(theta1)))
plot1 = new(4,graphic)
plot2 = new(4,graphic)
wks = gsn_open_wks ("x11","xy")
gsn_define_colormap(wks,(/"white","black","red","green","blue","dodgerblue3","firebrick"/))
;---Set common resources for both XY curves.
res = True
res@gsnMaximize = True
res@gsnDraw = False
res@gsnFrame = False
res@xyLineThicknessF = 2.0
res1 = res
res2 = res
;---Set individual resources for XY curves.
res1@xyLineColor = "blue"
res2@xyLineColor = "green"
;---Create each plot and store the 2nd plot as well.
do i=0,NPLOTS-1
plot1(i) = gsn_csm_x2y(wks,theta1,theta2,y(i,:),res1,res2)
plot2(i) = plot1@xy2
end do
;---Code to attach markers
mkres = True
mkres@gsMarkerIndex = 16 ; filled dot
dum1 = new(NPLOTS,graphic)
dum2 = new(NPLOTS,graphic)
;---Randomly put markers on both curves
do i=0,NPLOTS-1
;---Get some random index values
i1 = toint(random_uniform(0,NPTS-1,5))
i2 = toint(random_uniform(0,NPTS-1,5))
;---Add markers to first curve
mkres@gsMarkerColor = "dodgerblue3"
dum1(i) = gsn_add_polymarker(wks,plot1(i),theta1(i1),y(i,i1),mkres)
;---Add markers to second curve
mkres@gsMarkerColor = "firebrick"
dum2(i) = gsn_add_polymarker(wks,plot2(i),theta2(i2),y(i,i2),mkres)
end do
;---Panel
pres = True
pres@gsnMaximize = True
gsn_panel(wks,plot1,(/2,2/),pres)
end