mpl.pyplot.Text¶
-
class
mpl.pyplot.Text(x=0, y=0, text=u'', color=None, verticalalignment=u'baseline', horizontalalignment=u'left', multialignment=None, fontproperties=None, rotation=None, linespacing=None, rotation_mode=None, usetex=None, wrap=False, **kwargs)[source]¶ Handle storing and drawing of text in window or data coordinates.
-
__init__(x=0, y=0, text=u'', color=None, verticalalignment=u'baseline', horizontalalignment=u'left', multialignment=None, fontproperties=None, rotation=None, linespacing=None, rotation_mode=None, usetex=None, wrap=False, **kwargs)[source]¶ Create a
Textinstance at x, y with string text.- Valid kwargs are
- agg_filter: unknown
alpha: float (0.0 transparent through 1.0 opaque)
animated: [True | False]
axes: an
Axesinstance backgroundcolor: any matplotlib color bbox: FancyBboxPatch prop dict clip_box: amatplotlib.transforms.Bboxinstance clip_on: [True | False] clip_path: [ (Path,Transform) |Patch| None ] color: any matplotlib color contains: a callable function family or fontfamily or fontname or name: [FONTNAME | ‘serif’ | ‘sans-serif’ | ‘cursive’ | ‘fantasy’ | ‘monospace’ ] figure: amatplotlib.figure.Figureinstance fontproperties or font_properties: amatplotlib.font_manager.FontPropertiesinstance gid: an id string horizontalalignment or ha: [ ‘center’ | ‘right’ | ‘left’ ] label: string or anything printable with ‘%s’ conversion. linespacing: float (multiple of font size) multialignment: [‘left’ | ‘right’ | ‘center’ ] path_effects: unknown picker: [None|float|boolean|callable] position: (x,y) rasterized: [True | False | None] rotation: [ angle in degrees | ‘vertical’ | ‘horizontal’ ] rotation_mode: unknown size or fontsize: [size in points | ‘xx-small’ | ‘x-small’ | ‘small’ | ‘medium’ | ‘large’ | ‘x-large’ | ‘xx-large’ ] sketch_params: unknown snap: unknown stretch or fontstretch: [a numeric value in range 0-1000 | ‘ultra-condensed’ | ‘extra-condensed’ | ‘condensed’ | ‘semi-condensed’ | ‘normal’ | ‘semi-expanded’ | ‘expanded’ | ‘extra-expanded’ | ‘ultra-expanded’ ] style or fontstyle: [ ‘normal’ | ‘italic’ | ‘oblique’] text: string or anything printable with ‘%s’ conversion. transform:Transforminstance url: a url string usetex: unknown variant or fontvariant: [ ‘normal’ | ‘small-caps’ ] verticalalignment or va or ma: [ ‘center’ | ‘top’ | ‘bottom’ | ‘baseline’ ] visible: [True | False] weight or fontweight: [a numeric value in range 0-1000 | ‘ultralight’ | ‘light’ | ‘normal’ | ‘regular’ | ‘book’ | ‘medium’ | ‘roman’ | ‘semibold’ | ‘demibold’ | ‘demi’ | ‘bold’ | ‘heavy’ | ‘extra bold’ | ‘black’ ] wrap: unknown x: float y: float zorder: any number
-
Methods¶
__init__([x, y, text, color, ...]) |
Create a Text instance at x, y with string text. |
add_callback(func) |
Adds a callback function that will be called whenever one of the Artist‘s properties changes. |
contains(mouseevent) |
Test whether the mouse event occurred in the patch. |
convert_xunits(x) |
For artists in an axes, if the xaxis has units support, |
convert_yunits(y) |
For artists in an axes, if the yaxis has units support, |
draw(artist, renderer, *args, **kwargs) |
Draws the Text object to the given renderer. |
findobj([match, include_self]) |
Find artist objects. |
format_cursor_data(data) |
Return cursor data string formatted. |
get_agg_filter() |
return filter function to be used for agg filter |
get_alpha() |
Return the alpha value used for blending - not supported on all |
get_animated() |
Return the artist’s animated state |
get_axes() |
Return the Axes instance the artist resides in, or None. |
get_bbox_patch() |
Return the bbox Patch object. |
get_children() |
Return a list of the child Artist`s this :class:`Artist contains. |
get_clip_box() |
Return artist clipbox |
get_clip_on() |
Return whether artist uses clipping |
get_clip_path() |
Return artist clip path |
get_color() |
Return the color of the text |
get_contains() |
Return the _contains test used by the artist, or None for default. |
get_cursor_data(event) |
Get the cursor data for a given event. |
get_family() |
Return the list of font families used for font lookup |
get_figure() |
Return the Figure instance the artist belongs to. |
get_font_properties() |
alias for get_fontproperties |
get_fontfamily() |
alias for get_family |
get_fontname() |
alias for get_name |
get_fontproperties() |
Return the FontProperties object |
get_fontsize() |
alias for get_size |
get_fontstretch() |
alias for get_stretch |
get_fontstyle() |
alias for get_style |
get_fontvariant() |
alias for get_variant |
get_fontweight() |
alias for get_weight |
get_gid() |
Returns the group id |
get_ha() |
alias for get_horizontalalignment |
get_horizontalalignment() |
Return the horizontal alignment as string. |
get_label() |
Get the label used for this artist in the legend. |
get_name() |
Return the font name as string |
get_path_effects() |
|
get_picker() |
Return the picker object used by this artist |
get_position() |
Return the position of the text as a tuple (x, y) |
get_prop_tup() |
Return a hashable tuple of properties. |
get_rasterized() |
return True if the artist is to be rasterized |
get_rotation() |
return the text angle as float in degrees |
get_rotation_mode() |
get text rotation mode |
get_size() |
Return the font size as integer |
get_sketch_params() |
Returns the sketch parameters for the artist. |
get_snap() |
Returns the snap setting which may be: |
get_stretch() |
Get the font stretch as a string or number |
get_style() |
Return the font style as string |
get_text() |
Get the text as string |
get_transform() |
Return the Transform instance used by this artist. |
get_transformed_clip_path_and_affine() |
Return the clip path with the non-affine part of its transformation applied, and the remaining affine part of its transformation. |
get_unitless_position() |
Return the unitless position of the text as a tuple (x, y) |
get_url() |
Returns the url |
get_usetex() |
Return whether this Text object will render using TeX. |
get_va() |
alias for getverticalalignment() |
get_variant() |
Return the font variant as a string |
get_verticalalignment() |
Return the vertical alignment as string. |
get_visible() |
Return the artist’s visiblity |
get_weight() |
Get the font weight as string or number |
get_window_extent([renderer, dpi]) |
Return a Bbox object bounding the text, in display units. |
get_wrap() |
Returns the wrapping state for the text. |
get_zorder() |
Return the Artist‘s zorder. |
have_units() |
Return True if units are set on the x or y axes |
hitlist(event) |
List the children of the artist which contain the mouse event event. |
is_figure_set() |
Returns True if the artist is assigned to a Figure. |
is_math_text(s) |
Returns a cleaned string and a boolean flag. |
is_transform_set() |
Returns True if Artist has a transform explicitly set. |
pchanged() |
Fire an event when property changed, calling all of the registered callbacks. |
pick(mouseevent) |
call signature: |
pickable() |
Return True if Artist is pickable. |
properties() |
return a dictionary mapping property name -> value for all Artist props |
remove() |
Remove the artist from the figure if possible. |
remove_callback(oid) |
Remove a callback based on its id. |
set(**kwargs) |
A property batch setter. |
set_agg_filter(filter_func) |
set agg_filter fuction. |
set_alpha(alpha) |
Set the alpha value used for blending - not supported on all backends. |
set_animated(b) |
Set the artist’s animation state. |
set_axes(axes) |
Set the Axes instance in which the artist resides, if any. |
set_backgroundcolor(color) |
Set the background color of the text by updating the bbox. |
set_bbox(rectprops) |
Draw a bounding box around self. |
set_clip_box(clipbox) |
Set the artist’s clip Bbox. |
set_clip_on(b) |
Set whether artist uses clipping. |
set_clip_path(path[, transform]) |
Set the artist’s clip path, which may be: |
set_color(color) |
Set the foreground color of the text |
set_contains(picker) |
Replace the contains test used by this artist. |
set_family(fontname) |
Set the font family. |
set_figure(fig) |
Set the Figure instance the artist belongs to. |
set_font_properties(fp) |
alias for set_fontproperties |
set_fontname(fontname) |
alias for set_family |
set_fontproperties(fp) |
Set the font properties that control the text. |
set_fontsize(fontsize) |
alias for set_size |
set_fontstretch(stretch) |
alias for set_stretch |
set_fontstyle(fontstyle) |
alias for set_style |
set_fontvariant(variant) |
alias for set_variant |
set_fontweight(weight) |
alias for set_weight |
set_gid(gid) |
Sets the (group) id for the artist |
set_ha(align) |
alias for set_horizontalalignment |
set_horizontalalignment(align) |
Set the horizontal alignment to one of |
set_label(s) |
Set the label to s for auto legend. |
set_linespacing(spacing) |
Set the line spacing as a multiple of the font size. |
set_ma(align) |
alias for set_verticalalignment |
set_multialignment(align) |
Set the alignment for multiple lines layout. |
set_name(fontname) |
alias for set_family |
set_path_effects(path_effects) |
set path_effects, which should be a list of instances of |
set_picker(picker) |
Set the epsilon for picking used by this artist |
set_position(xy) |
Set the (x, y) position of the text |
set_rasterized(rasterized) |
Force rasterized (bitmap) drawing in vector backend output. |
set_rotation(s) |
Set the rotation of the text |
set_rotation_mode(m) |
set text rotation mode. If “anchor”, the un-rotated text |
set_size(fontsize) |
Set the font size. |
set_sketch_params([scale, length, randomness]) |
Sets the sketch parameters. |
set_snap(snap) |
Sets the snap setting which may be: |
set_stretch(stretch) |
Set the font stretch (horizontal condensation or expansion). |
set_style(fontstyle) |
Set the font style. |
set_text(s) |
Set the text string s |
set_transform(t) |
Set the Transform instance used by this artist. |
set_url(url) |
Sets the url for the artist |
set_usetex(usetex) |
Set this Text object to render using TeX (or not). |
set_va(align) |
alias for set_verticalalignment |
set_variant(variant) |
Set the font variant, either ‘normal’ or ‘small-caps’. |
set_verticalalignment(align) |
Set the vertical alignment |
set_visible(b) |
Set the artist’s visiblity. |
set_weight(weight) |
Set the font weight. |
set_wrap(wrap) |
Sets the wrapping state for the text. |
set_x(x) |
Set the x position of the text |
set_y(y) |
Set the y position of the text |
set_zorder(level) |
Set the zorder for the artist. |
update(kwargs) |
Update properties from a dictionary. |
update_bbox_position_size(renderer) |
Update the location and the size of the bbox. |
update_from(other) |
Copy properties from other to self |