PyNGL Home > Functions > Graphics routines

Ngl.text

Draws a text string on an existing plot.

Prototype

txt = Ngl.text(wks, plot, text, x, y, res=None)

Arguments

wks

The identifier returned from calling Ngl.open_wks.

plot

The id of the plot which you want to draw the text strings on.

text

The text string.

x, y

The x, y coordinates of the text string.

res=None

An optional variable containing a list of TextItem resources, attached as attributes.

Return value

txt

A PlotId of the text object created.

Description

This function draws a text string on the given plot. plot is the value returned from a previous call to one of the PyNGL plotting functions, like Ngl.xy, Ngl.contour_map, etc. x and y are scalars defining the coordinates of the text string, and resources can optionally contain an unlimited number of attributes that are resource names and their values. Note that x and y must be in the same data space as the data in plot.

The frame is not advanced when you call this function, so you need to call Ngl.frame yourself if you want to advance the frame.

If you plan to resize your plot or use it in a call to Ngl.panel, then it is better to use the function Ngl.add_text. With this function, the text string is attached to the plot and will automatically get resized when the plot is resized.

Missing values are not allowed in this procedure.

See Also

Ngl.add_text, Ngl.text_ndc

Examples

See examples ngl07p.py (output) and ngl10p.py (output).