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

Adam Phillips asphilli at ucar.edu
Wed Mar 2 16:01:36 MST 2016


Hi Sun,
(Please always include the ncl-talk email list on any replies.) As you do
have a frame(wks) call at the end of your script, can you set gsnDraw  and
gsnFrame = True, and send the resulting 4 images to the ncl-talk email list
so all can see?
Thanks,
Adam

On Wed, Mar 2, 2016 at 2:47 PM, mireiyue <mireiyue at gmail.com> wrote:

> 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
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>


-- 
Adam Phillips
Associate Scientist,  Climate and Global Dynamics Laboratory, NCAR
www.cgd.ucar.edu/staff/asphilli/   303-497-1726

<http://www.cgd.ucar.edu/staff/asphilli>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160302/b21221d0/attachment.html 


More information about the ncl-talk mailing list