C------------------------------------------------------------
C
      subroutine grafx1_elvis
C
C  plot to ELVIS server; caller has assured that there is one.
C  caller has also loaded data into trgraf_elvis module
C
      use trgraf_elvis
      implicit NONE
C
C-------------------
C  local
C
      real*8 lbloc(2)
      integer istat,i,ilogx,ilogy,igridx,igridy
      real*8 plotloc(2)
      real*8 width, height, h, xside, yside, hside
      real*8 r8min,r8max
C
      include 'GAXES_BLK'
      include 'GFTIC'
      include 'PLOT1MMX'
C
C  ELVIS block and local initialization...
C
      include 'ELVIS_H'
C-----------------------
C  make basic plot; turn off legend
C
      istat = ef_graphwindowcreate(trim(ewname), 1, 1)
      istat = ef_graphcreate(trim(egname), E_NO_INDEX)
      istat = ef_graphwindowaddgraph(trim(ewname), trim(egname), 0, 0)
C
      istat = ef_graphshowlegend(trim(egname), E_FALSE)
C
C  log/linear axes
C
      if(ixxmap(iaxcur).eq.1) then
         ilogx=E_LOGARITHMIC
      else
         ilogx=E_LINEAR
      endif

      if(ixymap(iaxcur).eq.1) then
         ilogy=E_LOGARITHMIC
      else
         ilogy=E_LINEAR
      endif

      istat = ef_graphsetxaxis(trim(egname), ilogx)
      istat = ef_graphsetyaxis(trim(egname), ilogy)

      if(kframx.ge.5) then
         igridx=E_TRUE
      else
         igridx=E_FALSE
      endif

      if(kframy.ge.5) then
         igridy=E_TRUE
      else
         igridy=E_FALSE
      endif

      istat = ef_graphsetXgrid(trim(egname), igridx)
      istat = ef_graphsetYgrid(trim(egname), igridy)
C
      r8min = xmin
      r8max = xmax
      istat = ef_graphsetXrange(trim(egname), r8min, r8max)
C
      r8min = ymin
      r8max = ymax
      istat = ef_graphsetYrange(trim(egname), r8min, r8max)
C
C set plot area to fill graphwindow -- no legend
      plotLoc(1) = .12d0
      plotLoc(2) = .14d0
      hside = 0.0325d0       ! monospaced char height for side labels
      width = .84d0 - 0.02d0*sidelab_len
      xside = plotloc(1) + width + hside
      h = .03d0
      height = .83d0-n_emnlab*h
      yside = plotloc(2) + height
C
      istat = ef_graphsetplotarea(trim(egname), plotloc, width, height)
C
      do i=1,nxy
         if(xylist(i)%itype.le.2) then
            istat = ef_fxdatasetcreate(xylist(i)%name, 
     >         xylist(i)%n, xylist(i)%x, xylist(i)%y)
            istat = ef_graphaddfxdataset(trim(egname), xylist(i)%name)
            if(klintp.lt.0) then
               istat = ef_showlines(xylist(i)%name, E_FALSE)
               istat = ef_showmarkers(xylist(i)%name, 1) ! symbols @ all pts
            else
               istat = ef_showlines(xylist(i)%name, E_TRUE)
               istat = ef_showmarkers(xylist(i)%name, 0) ! lines only
            endif
         endif
      enddo
C
      istat = ef_graphsetxlabel(trim(egname), trim(exuns))
      istat = ef_graphsetylabel(trim(egname), trim(eyuns))
      call trgraf_sname_get(esname)
      istat = ef_graphsettitle(trim(egname), trim(etitle), trim(esname))
C
C  run id label
C
      lbloc(1)=0.18d0
      lbloc(2)=0.98d0
      do i=1,n_emnlab
         lbloc(2)=lbloc(2)-h
         istat = ef_graphaddlabel(trim(egname),trim(emnlab(i)),
     >      lbloc,'SansSerif','Bold',h,"name: blue")
      enddo
C
C  side labels
C
      do i=1,n_sidelab
         yside=yside-hside
         lbloc(1)=xside; lbloc(2)=yside
         istat = ef_graphaddlabel(trim(egname),
     >      esidelab(i)(1:sidelab_len),lbloc,'Monospaced','Plain',
     >      hside,"name: black")
      enddo

      istat = ef_graphwindowdisplay(trim(ewname))
      call elvis_check(istat,'grafx1_elvis->ef_graphWindowDisplay')
C
      return
      end
