        parameter(n=28)
        parameter(m1=6181)
        parameter(m2=5285)
        parameter(m3=4348)
        parameter(m4=2923)
        real x(n),y1(m1),y2(m2),y3(m3),y4(m4)

        open(1,file='../data/agn_zspec.tbl',status='old')
	open(21,file='../data/gal_zpho_0.1.tbl',status='old')
	open(22,file='../data/gal_zpho_0.3.tbl',status='old')
	open(23,file='../data/gal_zpho_0.5.tbl',status='old')
	open(24,file='../data/gal_zpho_0.7.tbl',status='old')

        do 10 i=1,n
        read(1,'(f3.1)')x(i)
10	continue

        do 20 j=1,m1
        read(21,'(e15.4)')y1(j)
20	continue

        do 30 j=1,m2
        read(22,'(e15.4)')y2(j)
30	continue

        do 40 j=1,m3
        read(23,'(e15.4)')y3(j)
40	continue

        do 50 j=1,m4
        read(24,'(e15.4)')y4(j)
50	continue

c        call pgbegin(0,'N_z.eps/vcps',2,1)
        call pgbegin(0,'?',2,1)
        call pgpaper(0.0,0.4)
        call pgscf(2)
        call pgsls(1)
        call pgslw(3)
        call pgsch(2.0)

************ plot the N_AGN-zspec **********

        call pgenv(0.0,1.2,0.,10.,0,0)
        call pglabel('\fiz\d\frspec\u','\fiN\d\frAGN\u','')
        call pgtext(1.08,1.0,'(a)')
        call pghist(n,x,0.,1.3,13,1)


************ plot the N_gal-zpho **********

        call pgenv(-0.1,1.2,0.,1600.,0,0)
        call pglabel('\fiz\d\frpho\u','\fiN\d\frgal\u','')
	call pgtext(1.08,150.,'(b)')

	call pgsci(1)
        call pghist(m1,y1,0.,1.3,13,1)
	call pgsch(1.3)
	call pgmove(0.9,1450.)
	call pgdraw(1.1,1450.)
	call pgtext(0.6,1450.,'\fiP\d\frmem\u>0.1')

	call pgsci(2)
        call pghist(m2,y2,0.,1.3,13,1)
	call pgmove(0.9,1300.)
	call pgdraw(1.1,1300.)
	call pgtext(0.6,1300.,'\fiP\d\frmem\u>0.3')

	call pgsci(3)
        call pghist(m3,y3,0.,1.3,13,1)
	call pgmove(0.9,1150.)
	call pgdraw(1.1,1150.)
	call pgtext(0.6,1150.,'\fiP\d\frmem\u>0.5')

	call pgsci(4)
        call pghist(m4,y4,0.,1.3,13,1)
	call pgmove(0.9,1000.)
	call pgdraw(1.1,1000.)
	call pgtext(0.6,1000.,'\fiP\d\frmem\u>0.7')

        call pgend
        end
