PyNGL Home > Functions > Graphics routines


Draws a text string on an existing plot.


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



The identifier returned from calling Ngl.open_wks.


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


The text string.

x, y

The x, y coordinates of the text string.


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

Return value


A PlotId of the text object created.


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


See examples (output) and (output).