PyNGL resources overview

What a resource is

A resource is an attribute of a PyNGL Resources class object. Setting values for specified resources is how you modify the appearance of PyNGL graphics. Resources can be used to change everything from line colors, fonts, contour levels, map projections, vector colors, and so forth. There are over 1400 resources; links to detailed documentation for specific resources can be found on the PyNGL resources page.

Resource types

The first two lowercase letters of a resource name (or three in the case of some special resources) define the resource type. For example, "cn" for contour resources, "xy" for XY plot resources, "mp" for map resources, "ngl" for generic PyNGL resources, and so forth. A complete breakdown by resource type can be found on the PyNGL resources page.

Setting resource values

To set a resource value, you first need to create an instance of the Resources class, and then assign values to resources as attributes of that class object. A Resources class object is referred to as a "resource list" and such lists can be passed as arguments to any number of PyNGL graphics functions to control graphics appearance. For example:
   xyres = Ngl.Resources()          # Create an instance of a Resources class.
   xyres.xyLineColor      = "red"   # Change line color to red.
   xyres.xyLineThicknessF = 3.0     # Triple the line thickness.
   plot = Ngl.y(wks,y,xyres)

Relationship with NCL resources

PyNGL and NCL share resource names when the functionality is identical. To avoid redundant documentation, the NCL resource documentation is referenced where appropriate. Do not be disconcerted if you wind up in the NCL resource documentation pages.

Default settings

Most PyNGL resources have a default value, and the default values are documented along with each resource in the individual resource pages pointed to from the main PyNGL resource documentation page.

But, note well that PyNGL initializes some resource values differently from the documented NCL defaults and these are described on the "Default resource settings for PyNGL graphics" page.

Resource files

You can also set PyNGL resources in a hierarchy of resource files that get loaded when you run a PyNGL script. Resources set in a PyNGL script override any resources set in any resource files.


For examples of using resources, see most any of the PyNGL examples. To see if there's an example that uses a specific resource, browse the "Examples that use specified resources" list.

Here are a couple of code snippets showing how to set resources and apply them to PyNGL graphics functions:

   res = Ngl.Resources()
   res.gsLineDashPattern  = 4    
   res.xyDashPattern      = 4    
   res.xyDashPatterns     = (/2,5,12/) 
   xy = Ngl.xy(wks,x,y,res)
   rlist = Ngl.Resources()
   rlist.gsLineDashPattern =  4
   rlist.xyDashPattern     =  4
   rlist.xyDashPatterns    =  (/2,5,12/)