yt.visualization.plot_modifications.TextLabelCallback

class yt.visualization.plot_modifications.TextLabelCallback(pos, text, data_coords=False, coord_system='data', text_args=None, inset_box_args=None)[source]
annotate_text(pos, text, coord_system=’data’, text_args=None,
inset_box_args=None):

Overplot text on the plot at a specified position. If you desire an inset box around your text, set one with the inset_box_args dictionary keyword.

Parameters:

pos : 2- or 3-element tuple, list, or array

These are the coordinates where the text will be overplotted

text : string

The text you wish to include

coord_system : string, optional

This string defines the coordinate system of the coordinates of pos Valid coordinates are:

“data” – the 3D dataset coordinates

“plot” – the 2D coordinates defined by the actual plot limits

“axis” – the MPL axis coordinates: (0,0) is lower left; (1,1) is

upper right

“figure” – the MPL figure coordinates: (0,0) is lower left, (1,1)

is upper right

text_args : dictionary, optional

This dictionary is passed to the MPL text function for generating the text. By default, it is: {‘color’:’white’} and uses the defaults for the other fonts in the image.

inset_box_args : dictionary, optional

A dictionary of any arbitrary parameters to be passed to the Matplotlib FancyBboxPatch object as the inset box around the text. Default: {}

Examples

>>> # Overplot white text at data location [0.55, 0.7, 0.4] 
>>> import yt
>>> ds = yt.load('IsolatedGalaxy/galaxy0030/galaxy0030')
>>> s = yt.SlicePlot(ds, 'z', 'density')
>>> s.annotate_text([0.55, 0.7, 0.4], "Here is a galaxy")
>>> s.save()
>>> # Overplot yellow text at axis location [0.2, 0.8] with
>>> # a shaded inset box
>>> import yt
>>> ds = yt.load('IsolatedGalaxy/galaxy0030/galaxy0030')
>>> s = yt.SlicePlot(ds, 'z', 'density')
>>> s.annotate_text([0.2, 0.8], "Here is a galaxy", coord_system='axis',
...                 text_args={'color':'yellow'}, 
...                 inset_box_args={'boxstyle':'square,pad=0.3', 
...                                 'facecolor':'black', 
...                                 'linewidth':3, 
...                                 'edgecolor':'white', 'alpha':0.5})
>>> s.save()

Methods