[ncl-talk] legend colorfil problem

Marston Johnston shejo284 at gmail.com
Mon Jun 12 11:58:20 MDT 2017


Hi Adam,

 

It appears as if your example works only with a simple, single plot. In my example:

 

Begin

 

snip

 

plot = new(2,graphic)

 

snip

 

plot(2) = gsn_csm_xy(wks,zmas&lat,datace,res)

 

  gres = True

  gres at YPosPercent = 95.

  gres at XPosPercent = 5

  lineres = True

  lineres at lgLineColors = (/"blue","black","red","blue","black","red"/)

  lineres at lgLineThicknesses = 2.5

  lineres at LineLengthPercent = 9.0

  textres = True

  textres at lgLabels = (/"MCH1","MCH2","MCH3","OCH1","OCH2","OCH3"/)

  plot1 = simple_legend(wks,plot,gres,lineres,textres)

 

  resP = True

  resP at gsnMaximize = True

  resP at gsnPanelFigureStrings = str_upper((/"a","b","c"/))

  resP at gsnPanelFigureStringsFontHeightF = 0.01

  resP at amJust = "TopLeft"

  resP at gsnPanelBottom     = 0.05

  gsn_panel(wks,plot,(/3,1/),resP)

end 

 

results in an error:

 

fatal:["Execute.c":8640]:Execute: Error occurred at or near line 4952 in file $NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl

 

which is:

 

begin

  getvalues xyplot

    "trYMinF" : ymin

    "trYMaxF" : ymax

    "trXMinF" : xmin

    "trXMaxF" : xmax  ; line 4952

  end getvalues

 

snip

 

This requires some more digging but the author of the script should understand the problem a lot quicker. Perhaps there is a limitation on this simple_legend() function?


Appreciate your thoughts on this,

/M

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Marston S. Johnston, PhD

Department of Earth Sciences

University of Gothenburg, Sweden

Email: marston.johnston at gu.se

SkypeID: marston.johnston 

Phone: +46-31-7864901 

Only the fruitful thing is true!

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 

 

From: Adam Phillips <asphilli at ucar.edu>
Date: Monday, 12 June 2017 at 18:16
To: Marston Johnston <shejo284 at gmail.com>
Cc: NCL Talk <ncl-talk at ucar.edu>
Subject: Re: [ncl-talk] legend colorfil problem

 

Hi Marston,

simple_legend should be called before draw/frame are invoked. Thus, unless you are setting gsnDraw/gsnFrame = False in your panel resource list, simple_legend should be called before gsn_panel.

Adam 

 

On Mon, Jun 12, 2017 at 10:13 AM, Marston Johnston <shejo284 at gmail.com> wrote:

Hi Mary,

 

Thanks for the response. I think I’ll try Adam’s example but I was wondering if I’m using a panel plot, do I do this after the

Panel plot command?

 

Best,

/M

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Marston S. Johnston, PhD

Department of Earth Sciences

University of Gothenburg, Sweden

Email: marston.johnston at gu.se

SkypeID: marston.johnston 

Phone: +46-31-7864901 

Only the fruitful thing is true!

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 

 

From: Mary Haley <haley at ucar.edu>
Date: Monday, 12 June 2017 at 16:53
To: Marston Johnston <shejo284 at gmail.com>
Cc: NCL Talk <ncl-talk at ucar.edu>
Subject: Re: [ncl-talk] legend colorfil problem

 

Hi Marston,

 

There are two things you can try.

 

One is to use the new simple_legend function that Adam Phillips added.  See examples leg_16.ncl and leg_17.ncl at:

 

http://www.ncl.ucar.edu/Applications/legend.shtml#ex16

 

The second is I can give you a beta version of 6.5.0 that has the tmGridDrawOrder resource.  This allows you to make the grid lines draw in an earlier phase than the legend.  See example leg_18.ncl on the same page.

 

--Mary

 

 

On Sat, Jun 10, 2017 at 7:40 AM, Marston Johnston <shejo284 at gmail.com> wrote:

Hi,

 

I’m trying to get the legend on a xy plot to not show the gridlines by adding the following:

 

lgres at lgPerimFillColor   = "yellow"

lgres at lgPerimFill        = "SolidFill"

 

I’m doing this inside gsn_legend_ndc because I want the legend on plot(3) only:

 

  lgres                    = True

  lgres at lgLineColors       = (/"blue","black","red","blue","black","red"/)

  lgres at vpWidthF           = 0.15                   ; width of legend (NDC)

  lgres at vpHeightF          = 0.1                   ; height of legend (NDC)

  lgres at lgDashIndexes      = (/0,0,0,2,2,2/)              ; dash indexes

  lgres at LgLineThicknessF   = 2.0

  lgres at lgPerimFillColor   = "yellow"

  lgres at lgPerimFill        = "SolidFill"

  gsn_legend_ndc(wks,6,(/"MCH1","MCH2","MCH3","OCH1","OCH2","OCH3"/),0.6,0.2,lgres)

 

I can change the background color but the ”SolidFill” doesn’t seem to work. I’m calling  gsn_legend_ndc before the 

gsn_panel. Is this an issue where the plot is being added after the legend? I’ve looked at the tmGridDrawOrder but this doesn’t seem to work for gridlines in a xy plot. 

 

I’m using NCL version 6.4. Here’s the entire plot sequence:

 

  res = True

  res at gsnDraw = False

  res at gsnFrame = False

  res at tmXMajorGrid = True

  res at tmXMajorGridThicknessF = 1.0

  res at tmXMajorGridLineDashPattern = 2

  res at tmYMajorGrid = True

  res at tmYMajorGridThicknessF = 1.0

  res at tmYMajorGridLineDashPattern = 2

  res at xyLineColors = (/"blue","black","red","blue","black","red"/)

  res at xyLineThicknesses = (/1,1,1,1,1,1/)*2

  res at xyDashPatterns = (/0,0,0,2,2,2/)

  ;res at tiYAxisString = "~F8~T~B~B~N~ (K)"

  res at vpHeightF = 0.5

  res at vpWidthF = 1.5

  res at trXMinF = -90.0

  res at trXMaxF = 90.0

 

  res at trYMinF = 230.0

  res at trYMaxF = 280.0

 

  plot(0) = gsn_csm_xy(wks,zmas&lat,dataas,res)

  plot(1) = gsn_csm_xy(wks,zmas&lat,datacs,res)

 

  res at trYMinF = -4.0

  res at trYMaxF = 0.0

  res at tiXAxisString = "Latitude"

  plot(2) = gsn_csm_xy(wks,zmas&lat,datace,res)

 

  lgres                    = True

  lgres at lgLineColors       = (/"blue","black","red","blue","black","red"/)

  lgres at vpWidthF           = 0.15                   ; width of legend (NDC)

  lgres at vpHeightF          = 0.1                   ; height of legend (NDC)

  lgres at lgDashIndexes      = (/0,0,0,2,2,2/)              ; dash indexes

  lgres at LgLineThicknessF   = 2.0

  lgres at lgPerimFillColor   = "yellow"

  lgres at lgPerimFill        = "SolidFill"

  gsn_legend_ndc(wks,6,(/"MCH1","MCH2","MCH3","OCH1","OCH2","OCH3"/),0.6,0.2,lgres)

 

  resP = True

  resP at gsnMaximize = True

  resP at gsnPanelFigureStrings = str_upper((/"a","b","c"/))

  resP at gsnPanelFigureStringsFontHeightF = 0.01

  resP at amJust = "TopLeft"

  resP at gsnPanelBottom  = 0.05

  gsn_panel(wks,plot,(/3,1/),resP)

 

 

Thanks for your advice/help with this,

/M

   

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Marston S. Johnston, PhD

Department of Earth Sciences

University of Gothenburg, Sweden

Email: marston.johnston at gu.se

SkypeID: marston.johnston 

Phone: +46-31-7864901 

Only the fruitful thing is true!

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 


_______________________________________________
ncl-talk mailing list
ncl-talk at ucar.edu
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk

 


_______________________________________________
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 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170612/50664d69/attachment.html 


More information about the ncl-talk mailing list