scattertext#

metpy.plots.scattertext(ax, x, y, texts, loc=(0, 0), formatter=None, **kw)[source]#

Add text to the axes.

Add text in string s to axis at location x, y, data coordinates.

Parameters:
  • ax (matplotlib.axes.Axes) – Matplotlib Axes to draw on

  • x (array-like, (N, )) – Input positions

  • y (array-like, (N, )) – Input positions

  • texts (array-like, (N, )) – Collection of text that will be plotted at each (x,y) location

  • loc (tuple[int, int], optional) – Offset (in screen coordinates) from x,y position. Allows positioning text relative to original point. Default is (0, 0), which is no offset.

  • formatter (str or Callable, optional) – How to format the each entry in texts for plotting. If a string, it should be compatible with the format() builtin. If a callable, this should take a value and return a string. Default is None, which performs no formatting and requires every object in texts to be a str.

  • kwargs (TextCollection properties.) – Other miscellaneous text parameters.

Examples

Individual keyword arguments can be used to override any given parameter:

>>> ax = plt.gca()
>>> scattertext(ax, [0.25, 0.75], [0.25, 0.75], ['aa', 'bb'],
... fontsize=12)  
TextCollection

The default setting to to center the text at the specified x, y locations in data coordinates. The example below places the text above and to the right by 10 pixels:

>>> ax = plt.gca()
>>> scattertext(ax, [0.25, 0.75], [0.25, 0.75], ['aa', 'bb'],
... loc=(10, 10))  
TextCollection

Examples using metpy.plots.scattertext#

High/Low Analysis

High/Low Analysis

Plotting Fronts

Plotting Fronts