[ncl-talk] how to get rid of the front symbols in the legend?

dyjbean soybean dyjbean at gmail.com
Mon Sep 19 07:13:17 MDT 2016


hi,
   i ploted a figure with fitting function and R-squared coefficient in the
legend showed below:
  in the legend , there are symbols *black solid line* and *red point* existing
in the front of R-squared and the fitting function,
i want to get rid of the black solid line and red point in the legend,and
only leave the behind expression.
but i don't know which attribute can be assigned in my script as following:
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"

begin
;************************************************
; Read data from file [time, value].
; Missing values (_FillValue) indicated by -9999.0
;************************************************

   txtfiles=systemfunc("ls *.txt")
   nfiles=dimsizes(txtfiles)

   do i=0,nfiles-1

   ncol  = 3
   ;nrow  = systemfunc("wc -l "+txtfiles(i))
   nrow  = numAsciiRow(txtfiles(i))
   data  = asciiread(txtfiles(i), (/nrow,ncol/), "float")
   data at _FillValue = -999.0

   y     = data(:,0)              ; O3
   x1    = data(:,1)              ; NO2
   x2    = data(:,2)              ; CO

   xvaro3=variance(y)

;************************************************
; calculate the regression coefficient (slope)
;************************************************
   rc1    = regline(x1, y)          ; slope
   rc1 at units = "DU"
   print(rc1)

   x1resvaro3 = variance((y-(rc1*x1+rc1 at yintercept)))
   cod1 =  1.0-(x1resvaro3/xvaro3)

   rc2    = regline(x2, y)          ; slope
   rc2 at units = "DU"
   print(rc2)

   x2resvaro3 = variance((y-(rc2*x2+rc2 at yintercept)))
   cod2 =  1.0-(x2resvaro3/xvaro3)

;************************************************
; create an array to hold both the original data
; and the calculated regression line
;     ---------
;     y = mx+b
;     m is the slope:       rc      returned from regline
;     b is the y intercept: rc at yave attribute of rc returned from regline
;************************************************

;;; O3->NO2
   pltarry1   = new ( (/2,nrow/), typeof(data), data at _FillValue)

   pltarry1(0,:) = y                                 ; use markers
   pltarry1(1,:) = rc1*(x1-rc1 at xave) + rc1 at yave          ; use solid line

;;;; O3->CO
   pltarry2   = new ( (/2,nrow/), typeof(data), data at _FillValue)

   pltarry2(0,:) = y                                 ; use markers
   pltarry2(1,:) = rc2*(x2-rc2 at xave) + rc2 at yave      ; use solid line


;************************************************
; plotting parameters
; This illustrates one approach. Overlays could also be used.
;************************************************
   rmfiles=systemfunc("rm "+"2010_678.png")
   wks  = gsn_open_wks("png","2010_678")

   res                     = True                   ; plot mods desired
   res at gsnDraw               = False
   res at gsnFrame              = False
   res at xyMarkLineModes     = (/"Markers","Lines"/)  ;
choose which have markers
   res at xyMarkers           = 16                     ; choose type of marker
   res at xyMarkerColor       = "red"                  ; Marker color
   res at xyMarkerSizeF       = 0.01                  ;
Marker size (default 0.01)
   res at xyDashPatterns      = 1                       ; solid line
   res at xyLineThicknesses   = (/1,2/)                ; set second line to 2
   res at tmYLFormat          = "f"                    ; not
necessary but nicer labels
   ;res at lgPerimOn           =  False

   res at pmLegendDisplayMode    = "Always"            ; turn on legend

     ;res at tiMainString        = "Output from regline"  ; title
   res1  =  True
   res1  =  res

   ;res1 at lgLineLabelsOn  =  False
   res1 at pmLegendSide           = "Bottom"               ;
Change location of
   res1 at pmLegendParallelPosF   = .63                 ; move units right
   res1 at pmLegendOrthogonalPosF = -0.5                ; move units down

   res1 at pmLegendWidthF         = 0.15                ; Change width and
   res1 at pmLegendHeightF        = 0.18                ; height of legend.
   res1 at lgLabelFontHeightF     = .02                 ; change font height

   res1 at tiYAxisString      =  "O3(DU)"
   res1 at tiXAxisString      =  "NO2(DU)"


   ;; it function and R-squared
   x1ff ="y="+tostring(rc1)+"*x"+"+"+tostring(rc1 at yintercept)
   x1fr2="R~S~2~N~="+tostring(cod1)

   print(x1ff)
   print(x1fr2)

   res1 at xyExplicitLabels   =(/x1ff,x1fr2/)

   plot1  = gsn_csm_xy (wks,x1,pltarry1,res1)           ; create plot

   res2  =  True
   res2  =  res

   ;res2 at lgLineLabelsOn  =  False
   res2 at pmLegendSide           = "Bottom"               ;
Change location of
   res2 at pmLegendParallelPosF   = .65                 ; move units right
   res2 at pmLegendOrthogonalPosF = -0.5                ; move units down

   res2 at pmLegendWidthF         = 0.15                ; Change width and
   res2 at pmLegendHeightF        = 0.18                ; height of legend.
   res2 at lgLabelFontHeightF     = .02                 ; change font height

   res2 at tiYAxisString      =  "O3(DU)"
   res2 at tiXAxisString      =  "CO(DU)"


   ;; fit function and R-squared
   x2ff = "y="+tostring(rc2)+"*x"+"+"+tostring(rc2 at yintercept)
   x2fr2 = "R~S~2~N~="+tostring(cod2)

   res2 at xyExplicitLabels   =(/x2ff,x2fr2/)

   plot2  = gsn_csm_xy (wks,x2,pltarry2,res2)           ; create plot

   ;---Draw both plot in a panel.
   pres                  = True
   pres at gsnMaximize      = True
   ;pres at gsnPanelLabelBar = True
   pres at txString           = "2010 summer"
   ;pres at pmLabelBarWidthF = 0.6
   pres at lbLabelFontHeightF  = 0.01              ; make labels smaller

   gsn_panel(wks,(/plot1,plot2/),(/1,2/),pres)

   delete([/pltarry1,pltarry2/])
   delete([/res,res1,res2/])
   delete([/rc1,rc2/])
   delete(data)
   delete([/x1resvaro3,x2resvaro3,cod1,cod2/])
   delete([/x1ff,x1fr2,x2ff,x2fr2/])



 end do


end

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++

 any help would be appreciated!



------------------------------
dyjbean at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160919/6cb65e71/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: InsertPic_.png
Type: image/png
Size: 106014 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160919/6cb65e71/attachment.png 


More information about the ncl-talk mailing list