[ncl-talk] Need help for plotting multiple regression lines in one plot

mireiyue mireiyue at gmail.com
Wed Mar 2 14:47:05 MST 2016


Dear NCL users

I am trying to plot three different data with three regression lines in one plot. I can plot all data in one plot but the regression line only plot the first one.  How I can plot all three regression lines in one plot? I do appreciate any helps!! Thank you!!

Sun-

 rc =  regline_stats(calextd,merracmf)
 print(rc)
 pltarry   = new((/2,dimsizes(calextd)/),typeof(calextd))
 pltarry(0,:) = merracmf                                ; use markers
 pltarry(1,:) = rc*(calextd-rc at xave) + rc at yintercept          ; use solid line
 printVarSummary(pltarry)

 rc1 = regline_stats(camMextd,camMcmf)
 print(rc1)
 pltarry1   = new((/2,dimsizes(camMextd)/),typeof(camMextd))
 pltarry1(0,:) = camMcmf                                ; use markers
 pltarry1(1,:) = rc*(camMextd-rc at xave) + rc at yintercept          ; use solid line
 printVarSummary(pltarry1)

 rc2 = regline_stats(camextd,camcmf)
 print(rc2)
 pltarry2   = new((/2,dimsizes(camextd)/),typeof(camextd))
 pltarry2(0,:) = camcmf                                ; use markers
 pltarry2(1,:) = rc*(camextd-rc at xave) + rc at yintercept          ; use solid line
 printVarSummary(pltarry2)

wks   = gsn_open_wks("eps","Global")
res                   = True                     ; plot mods desired
res at gsnDraw     = False      ; Will draw later, after overlaying
res at gsnFrame    = False      ; all plots
; res at gsnMaximize       = False
res at trXMinF              = 0.      
res at trYMinF              = 0.

res at xyMarkLineModes   = (/“Markers”,”Lines”/) ; choose which have markers
res at xyExplicitLegendLabels = “A"
res at pmLegendParallelPosF   = 0.35
res at xyMarkers         = "16"                     ; choose type of marker
res at xyMarkerColor     = "darkgreen"              ; Marker color
res at xyMarkerSizeF       = 0.01                  ; Marker size (default 0.01)
res at xyLineColor         = "black"
res at xyLineThicknesses   = 1 ;(/1,2/)
res at xyDashPatterns      = 0                      ; solid line
plot2  = gsn_csm_xy (wks,calextd,pltarry(0:1,:),res)

res at xyMarkers         = "7"                     ; choose type of marker
res at xyMarkerColor     = "blue"              ; Marker color
res at xyMarkerSizeF       = 0.01                  ; Marker size (default 0.01)
res at xyExplicitLegendLabels = “B"
res at pmLegendParallelPosF   = 0.79
res at xyLineColor         = "red"
res at xyLineThicknesses   = 1 ;(/1,2/)
res at xyDashPatterns      = 0                      ; solid line
plot1  = gsn_csm_xy (wks,camMextd,pltarry1(0:1,:),res)

res at xyExplicitLegendLabels = “C"
res at pmLegendParallelPosF   = 1.2
res at xyMarkers         = "12"                     ; choose type of marker
res at xyMarkerColor     = "red"              ; Marker color
res at xyMarkerSizeF       = 0.01                  ; Marker size (default 0.01)
res at xyLineColor         = "blue"
res at xyLineThicknesses   = 1 ;(/1,2/)
res at xyDashPatterns      = 0                      ; solid line
plot =gsn_csm_xy (wks,camextd,pltarry2(0:1,:),res)

overlay(plot,plot1)
overlay(plot,plot2)
draw(plot)            ; This will draw all four plots

-------------- next part --------------
A non-text attachment was scrubbed...
Name: Global copy.pdf
Type: application/pdf
Size: 1259406 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160302/ec326537/attachment-0001.pdf 


More information about the ncl-talk mailing list