![](/Images/NCL_NCAR_NSF_banner.png)
gsn_create_legend
Creates a legend.
Prototype
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" ; This library is automatically loaded ; from NCL V6.2.0 onward. ; No need for user to explicitly load. function gsn_create_legend ( wks [1] : graphic, nitems [1] : integer, labels [*] : string, res [1] : logical ) return_val [1] : graphic
Arguments
wksA Workstation identifier. The identifier is one returned either from calling gsn_open_wks or calling create to create a Workstation object.
nitemsThe number of legend items you want.
labelsAn array of strings (of length nitems) containing the legend labels for each legend item.
resA variable containing an optional list of legend resources, attached as attributes. Set to True if you want the attached attributes to be applied, and False if you either don't have any resources to set, or you don't want the resources applied.
Return value
A scalar id of the legend created is returned. This is useful if you want to use gsn_add_annotation to attach the legend to a plot.
Description
This function creates a legend, given the number of items and labels for each item and returns an id for the legend. Note that this function does not draw the legend. To do this, you must call draw and pass it the legend id created.
This function is similar to the procedure gsn_legend_ndc, except it returns the legend id.
See Also
gsn_legend_ndc, gsn_create_labelbar, gsn_create_text, gsn_add_annotation
Examples
For some application examples, see:
- Legends example 8