| |
- matplotlib.artist.Artist
-
- Text
-
- Annotation
- TextWithDash
class Annotation(Text) |
|
A Text class to make annotating things in the figure: Figure,
Axes, Point, Rectangle, etc... easier |
|
- Method resolution order:
- Annotation
- Text
- matplotlib.artist.Artist
Methods defined here:
- __init__(self, s, xy, xycoords='data', xytext=None, textcoords=None, arrowprops=None, **kwargs)
- Annotate the x,y point xy with text s at x,y location xytext
(xytext if None defaults to xy and textcoords if None defaults
to xycoords).
arrowprops, if not None, is a dictionary of line properties
(see matplotlib.lines.Line2D) for the arrow that connects
annotation to the point. Valid keys are
- width : the width of the arrow in points
- frac : the fraction of the arrow length occupied by the head
- headwidth : the width of the base of the arrow head in points
- shrink: often times it is convenient to have the arrowtip
and base a bit away from the text and point being
annotated. If d is the distance between the text and
annotated point, shrink will shorten the arrow so the tip
and base are shink percent of the distance d away from the
endpoints. ie, shrink=0.05 is 5%
- any key for matplotlib.patches.polygon
xycoords and textcoords are a string that indicates the
coordinates of xy and xytext.
'figure points' : points from the lower left corner of the figure
'figure pixels' : pixels from the lower left corner of the figure 'figure fraction' : 0,0 is lower left of figure and 1,1 is upper, right
'axes points' : points from lower left corner of axes
'axes pixels' : pixels from lower left corner of axes
'axes fraction' : 0,1 is lower left of axes and 1,1 is upper right
'data' : use the coordinate system of the object being annotated (default)
'polar' : you can specify theta, r for the annotation, even
in cartesian plots. Note that if you
are using a polar axes, you do not need
to specify polar for the coordinate
system since that is the native"data" coordinate system.
If a points or pixels option is specified, values will be
added to the left, bottom and if negative, values will be
subtracted from the top, right. Eg,
# 10 points to the right of the left border of the axes and
# 5 points below the top border
xy=(10,-5), xycoords='axes points'
- draw(self, renderer)
- update_positions(self, renderer)
Methods inherited from Text:
- get_color(self)
- Return the color of the text
- get_font_properties(self)
- Return the font object
- get_fontname(self)
- alias for get_name
- get_fontsize(self)
- alias for get_size
- get_fontstyle(self)
- alias for get_style
- get_fontweight(self)
- alias for get_weight
- get_ha(self)
- alias for get_horizontalalignment
- get_horizontalalignment(self)
- Return the horizontal alignment as string
- get_name(self)
- Return the font name as string
- get_position(self)
- Return x, y as tuple
- get_prop_tup(self)
- Return a hashable tuple of properties
Not intended to be human readable, but useful for backends who
want to cache derived information about text (eg layouts) and
need to know if the text has changed
- get_rotation(self)
- return the text angle as float
- get_rotation_matrix(self, x0, y0)
- get_size(self)
- Return the font size as integer
- get_style(self)
- Return the font style as string
- get_text(self)
- Get the text as string
- get_va(self)
- alias for getverticalalignment
- get_verticalalignment(self)
- Return the vertical alignment as string
- get_weight(self)
- Get the font weight as string
- get_window_extent(self, renderer=None)
- is_math_text(self)
- set_backgroundcolor(self, color)
- Set the background color of the text
ACCEPTS: any matplotlib color
- set_bbox(self, rectprops)
- Draw a bounding box around self. rect props are any settable
properties for a rectangle, eg color='r', alpha=0.5
ACCEPTS: rectangle prop dict plus key 'pad' which is a pad in points
- set_color(self, color)
- Set the foreground color of the text
ACCEPTS: any matplotlib color
- set_family(self, fontname)
- Set the font family
ACCEPTS: [ 'serif' | 'sans-serif' | 'cursive' | 'fantasy' | 'monospace' ]
- set_fontname(self, fontname)
- alias for set_name
- set_fontproperties(self, fp)
- Set the font properties that control the text
ACCEPTS: a matplotlib.font_manager.FontProperties instance
- set_fontsize(self, fontsize)
- alias for set_size
- set_fontstyle(self, fontstyle)
- alias for set_style
- set_fontweight(self, weight)
- alias for set_weight
- set_ha(self, align)
- alias for set_horizontalalignment
- set_horizontalalignment(self, align)
- Set the horizontal alignment to one of
ACCEPTS: [ 'center' | 'right' | 'left' ]
- set_ma(self, align)
- alias for set_verticalalignment
- set_multialignment(self, align)
- Set the alignment for multiple lines layout. The layout of the
bounding box of all the lines is determined bu the horizontalalignment
and verticalalignment properties, but the multiline text within that
box can be
ACCEPTS: ['left' | 'right' | 'center' ]
- set_name(self, fontname)
- Set the font name,
ACCEPTS: string eg, ['Sans' | 'Courier' | 'Helvetica' ...]
- set_position(self, xy)
- Set the xy position of the text
ACCEPTS: (x,y)
- set_rotation(self, s)
- Set the rotation of the text
ACCEPTS: [ angle in degrees 'vertical' | 'horizontal'
- set_size(self, fontsize)
- Set the font size, eg, 8, 10, 12, 14...
ACCEPTS: [ size in points | relative size eg 'smaller', 'x-large' ]
- set_style(self, fontstyle)
- Set the font style
ACCEPTS: [ 'normal' | 'italic' | 'oblique']
- set_text(self, s)
- Set the text string s
ACCEPTS: string
- set_va(self, align)
- alias for set_verticalalignment
- set_variant(self, variant)
- Set the font variant, eg,
ACCEPTS: [ 'normal' | 'small-caps' ]
- set_verticalalignment(self, align)
- Set the vertical alignment
ACCEPTS: [ 'center' | 'top' | 'bottom' ]
- set_weight(self, weight)
- Set the font weight
ACCEPTS: [ 'normal' | 'bold' | 'heavy' | 'light' | 'ultrabold' | 'ultralight']
- set_x(self, x)
- Set the x position of the text
ACCEPTS: float
- set_y(self, y)
- Set the y position of the text
ACCEPTS: float
- update_from(self, other)
- Copy properties from other to self
Data and other attributes inherited from Text:
- zorder = 3
Methods inherited from matplotlib.artist.Artist:
- add_callback(self, func)
- get_alpha(self)
- Return the alpha value used for blending - not supported on all
backends
- get_animated(self)
- return the artist's animated state
- get_clip_box(self)
- Return artist clipbox
- get_clip_on(self)
- Return whether artist uses clipping
- get_figure(self)
- return the figure instance
- get_label(self)
- get_transform(self)
- return the Transformation instance used by this artist
- get_visible(self)
- return the artist's visiblity
- get_zorder(self)
- is_figure_set(self)
- is_transform_set(self)
- Artist has transform explicity let
- pchanged(self)
- fire event when property changed
- remove_callback(self, oid)
- set(self, **kwargs)
- A tkstyle set command, pass kwargs to set properties
- set_alpha(self, alpha)
- Set the alpha value used for blending - not supported on
all backends
ACCEPTS: float
- set_animated(self, b)
- set the artist's animation state
ACCEPTS: [True | False]
- set_clip_box(self, clipbox)
- Set the artist's clip Bbox
ACCEPTS: a matplotlib.transform.Bbox instance
- set_clip_on(self, b)
- Set whether artist uses clipping
ACCEPTS: [True | False]
- set_figure(self, fig)
- Set the figure instance the artist belong to
ACCEPTS: a matplotlib.figure.Figure instance
- set_label(self, s)
- Set the line label to s for auto legend
ACCEPTS: any string
- set_lod(self, on)
- Set Level of Detail on or off. If on, the artists may examine
things like the pixel width of the axes and draw a subset of
their contents accordingly
ACCEPTS: [True | False]
- set_transform(self, t)
- set the Transformation instance used by this artist
ACCEPTS: a matplotlib.transform transformation instance
- set_visible(self, b)
- set the artist's visiblity
ACCEPTS: [True | False]
- set_zorder(self, level)
- Set the zorder for the artist
ACCEPTS: any number
- update(self, props)
Data and other attributes inherited from matplotlib.artist.Artist:
- aname = 'Artist'
|
class Text(matplotlib.artist.Artist) |
|
Handle storing and drawing of text in window or data coordinates |
|
Methods defined here:
- __init__(self, x=0, y=0, text='', color=None, verticalalignment='bottom', horizontalalignment='left', multialignment=None, fontproperties=None, rotation=None, **kwargs)
- draw(self, renderer)
- get_color(self)
- Return the color of the text
- get_font_properties(self)
- Return the font object
- get_fontname(self)
- alias for get_name
- get_fontsize(self)
- alias for get_size
- get_fontstyle(self)
- alias for get_style
- get_fontweight(self)
- alias for get_weight
- get_ha(self)
- alias for get_horizontalalignment
- get_horizontalalignment(self)
- Return the horizontal alignment as string
- get_name(self)
- Return the font name as string
- get_position(self)
- Return x, y as tuple
- get_prop_tup(self)
- Return a hashable tuple of properties
Not intended to be human readable, but useful for backends who
want to cache derived information about text (eg layouts) and
need to know if the text has changed
- get_rotation(self)
- return the text angle as float
- get_rotation_matrix(self, x0, y0)
- get_size(self)
- Return the font size as integer
- get_style(self)
- Return the font style as string
- get_text(self)
- Get the text as string
- get_va(self)
- alias for getverticalalignment
- get_verticalalignment(self)
- Return the vertical alignment as string
- get_weight(self)
- Get the font weight as string
- get_window_extent(self, renderer=None)
- is_math_text(self)
- set_backgroundcolor(self, color)
- Set the background color of the text
ACCEPTS: any matplotlib color
- set_bbox(self, rectprops)
- Draw a bounding box around self. rect props are any settable
properties for a rectangle, eg color='r', alpha=0.5
ACCEPTS: rectangle prop dict plus key 'pad' which is a pad in points
- set_color(self, color)
- Set the foreground color of the text
ACCEPTS: any matplotlib color
- set_family(self, fontname)
- Set the font family
ACCEPTS: [ 'serif' | 'sans-serif' | 'cursive' | 'fantasy' | 'monospace' ]
- set_fontname(self, fontname)
- alias for set_name
- set_fontproperties(self, fp)
- Set the font properties that control the text
ACCEPTS: a matplotlib.font_manager.FontProperties instance
- set_fontsize(self, fontsize)
- alias for set_size
- set_fontstyle(self, fontstyle)
- alias for set_style
- set_fontweight(self, weight)
- alias for set_weight
- set_ha(self, align)
- alias for set_horizontalalignment
- set_horizontalalignment(self, align)
- Set the horizontal alignment to one of
ACCEPTS: [ 'center' | 'right' | 'left' ]
- set_ma(self, align)
- alias for set_verticalalignment
- set_multialignment(self, align)
- Set the alignment for multiple lines layout. The layout of the
bounding box of all the lines is determined bu the horizontalalignment
and verticalalignment properties, but the multiline text within that
box can be
ACCEPTS: ['left' | 'right' | 'center' ]
- set_name(self, fontname)
- Set the font name,
ACCEPTS: string eg, ['Sans' | 'Courier' | 'Helvetica' ...]
- set_position(self, xy)
- Set the xy position of the text
ACCEPTS: (x,y)
- set_rotation(self, s)
- Set the rotation of the text
ACCEPTS: [ angle in degrees 'vertical' | 'horizontal'
- set_size(self, fontsize)
- Set the font size, eg, 8, 10, 12, 14...
ACCEPTS: [ size in points | relative size eg 'smaller', 'x-large' ]
- set_style(self, fontstyle)
- Set the font style
ACCEPTS: [ 'normal' | 'italic' | 'oblique']
- set_text(self, s)
- Set the text string s
ACCEPTS: string
- set_va(self, align)
- alias for set_verticalalignment
- set_variant(self, variant)
- Set the font variant, eg,
ACCEPTS: [ 'normal' | 'small-caps' ]
- set_verticalalignment(self, align)
- Set the vertical alignment
ACCEPTS: [ 'center' | 'top' | 'bottom' ]
- set_weight(self, weight)
- Set the font weight
ACCEPTS: [ 'normal' | 'bold' | 'heavy' | 'light' | 'ultrabold' | 'ultralight']
- set_x(self, x)
- Set the x position of the text
ACCEPTS: float
- set_y(self, y)
- Set the y position of the text
ACCEPTS: float
- update_from(self, other)
- Copy properties from other to self
Data and other attributes defined here:
- zorder = 3
Methods inherited from matplotlib.artist.Artist:
- add_callback(self, func)
- get_alpha(self)
- Return the alpha value used for blending - not supported on all
backends
- get_animated(self)
- return the artist's animated state
- get_clip_box(self)
- Return artist clipbox
- get_clip_on(self)
- Return whether artist uses clipping
- get_figure(self)
- return the figure instance
- get_label(self)
- get_transform(self)
- return the Transformation instance used by this artist
- get_visible(self)
- return the artist's visiblity
- get_zorder(self)
- is_figure_set(self)
- is_transform_set(self)
- Artist has transform explicity let
- pchanged(self)
- fire event when property changed
- remove_callback(self, oid)
- set(self, **kwargs)
- A tkstyle set command, pass kwargs to set properties
- set_alpha(self, alpha)
- Set the alpha value used for blending - not supported on
all backends
ACCEPTS: float
- set_animated(self, b)
- set the artist's animation state
ACCEPTS: [True | False]
- set_clip_box(self, clipbox)
- Set the artist's clip Bbox
ACCEPTS: a matplotlib.transform.Bbox instance
- set_clip_on(self, b)
- Set whether artist uses clipping
ACCEPTS: [True | False]
- set_figure(self, fig)
- Set the figure instance the artist belong to
ACCEPTS: a matplotlib.figure.Figure instance
- set_label(self, s)
- Set the line label to s for auto legend
ACCEPTS: any string
- set_lod(self, on)
- Set Level of Detail on or off. If on, the artists may examine
things like the pixel width of the axes and draw a subset of
their contents accordingly
ACCEPTS: [True | False]
- set_transform(self, t)
- set the Transformation instance used by this artist
ACCEPTS: a matplotlib.transform transformation instance
- set_visible(self, b)
- set the artist's visiblity
ACCEPTS: [True | False]
- set_zorder(self, level)
- Set the zorder for the artist
ACCEPTS: any number
- update(self, props)
Data and other attributes inherited from matplotlib.artist.Artist:
- aname = 'Artist'
|
class TextWithDash(Text) |
|
This is basically a Text with a dash (drawn with a Line2D)
before/after it. It is intended to be a drop-in replacement
for Text, and should behave identically to Text when
dashlength=0.0.
The dash always comes between the point specified by
set_position() and the text. When a dash exists, the
text alignment arguments (horizontalalignment,
verticalalignment) are ignored.
dashlength is the length of the dash in canvas units.
(default=0.0).
dashdirection is one of 0 or 1, where 0 draws the dash
after the text and 1 before.
(default=0).
dashrotation specifies the rotation of the dash, and
should generally stay None. In this case
get_dashrotation() returns get_rotation().
(I.e., the dash takes its rotation from the text's
rotation). Because the text center is projected onto
the dash, major deviations in the rotation cause
what may be considered visually unappealing results.
(default=None).
dashpad is a padding length to add (or subtract) space
between the text and the dash, in canvas units.
(default=3).
dashpush "pushes" the dash and text away from the point
specified by set_position() by the amount in canvas units.
(default=0)
NOTE: The alignment of the two objects is based on the
bbox of the Text, as obtained by get_window_extent().
This, in turn, appears to depend on the font metrics
as given by the rendering backend. Hence the quality
of the "centering" of the label text with respect to
the dash varies depending on the backend used.
NOTE2: I'm not sure that I got the get_window_extent()
right, or whether that's sufficient for providing the
object bbox. |
|
- Method resolution order:
- TextWithDash
- Text
- matplotlib.artist.Artist
Methods defined here:
- __init__(self, x=0, y=0, text='', color=None, verticalalignment='center', horizontalalignment='center', multialignment=None, fontproperties=None, rotation=None, dashlength=0.0, dashdirection=0, dashrotation=None, dashpad=3, dashpush=0, xaxis=True)
- draw(self, renderer)
- get_dashdirection(self)
- get_dashlength(self)
- get_dashpad(self)
- get_dashpush(self)
- get_dashrotation(self)
- get_figure(self)
- return the figure instance
- get_position(self)
- Return x, y as tuple
- get_window_extent(self, renderer=None)
- set_dashdirection(self, dd)
- Set the direction of the dash following the text.
1 is before the text and 0 is after. The default
is 0, which is what you'd want for the typical
case of ticks below and on the left of the figure.
ACCEPTS: int
- set_dashlength(self, dl)
- Set the length of the dash.
ACCEPTS: float
- set_dashpad(self, dp)
- Set the "pad" of the TextWithDash, which
is the extra spacing between the dash and
the text, in canvas units.
ACCEPTS: float
- set_dashpush(self, dp)
- Set the "push" of the TextWithDash, which
is the extra spacing between the beginning
of the dash and the specified position.
ACCEPTS: float
- set_dashrotation(self, dr)
- Set the rotation of the dash.
ACCEPTS: float
- set_figure(self, fig)
- Set the figure instance the artist belong to.
ACCEPTS: a matplotlib.figure.Figure instance
- set_position(self, xy)
- Set the xy position of the TextWithDash.
ACCEPTS: (x,y)
- set_transform(self, t)
- Set the Transformation instance used by this artist.
ACCEPTS: a matplotlib.transform transformation instance
- set_x(self, x)
- Set the x position of the TextWithDash.
ACCEPTS: float
- set_y(self, y)
- Set the y position of the TextWithDash.
ACCEPTS: float
- update_coords(self, renderer)
- Computes the actual x,y coordinates for
text based on the input x,y and the
dashlength. Since the rotation is with respect
to the actual canvas's coordinates we need to
map back and forth.
Methods inherited from Text:
- get_color(self)
- Return the color of the text
- get_font_properties(self)
- Return the font object
- get_fontname(self)
- alias for get_name
- get_fontsize(self)
- alias for get_size
- get_fontstyle(self)
- alias for get_style
- get_fontweight(self)
- alias for get_weight
- get_ha(self)
- alias for get_horizontalalignment
- get_horizontalalignment(self)
- Return the horizontal alignment as string
- get_name(self)
- Return the font name as string
- get_prop_tup(self)
- Return a hashable tuple of properties
Not intended to be human readable, but useful for backends who
want to cache derived information about text (eg layouts) and
need to know if the text has changed
- get_rotation(self)
- return the text angle as float
- get_rotation_matrix(self, x0, y0)
- get_size(self)
- Return the font size as integer
- get_style(self)
- Return the font style as string
- get_text(self)
- Get the text as string
- get_va(self)
- alias for getverticalalignment
- get_verticalalignment(self)
- Return the vertical alignment as string
- get_weight(self)
- Get the font weight as string
- is_math_text(self)
- set_backgroundcolor(self, color)
- Set the background color of the text
ACCEPTS: any matplotlib color
- set_bbox(self, rectprops)
- Draw a bounding box around self. rect props are any settable
properties for a rectangle, eg color='r', alpha=0.5
ACCEPTS: rectangle prop dict plus key 'pad' which is a pad in points
- set_color(self, color)
- Set the foreground color of the text
ACCEPTS: any matplotlib color
- set_family(self, fontname)
- Set the font family
ACCEPTS: [ 'serif' | 'sans-serif' | 'cursive' | 'fantasy' | 'monospace' ]
- set_fontname(self, fontname)
- alias for set_name
- set_fontproperties(self, fp)
- Set the font properties that control the text
ACCEPTS: a matplotlib.font_manager.FontProperties instance
- set_fontsize(self, fontsize)
- alias for set_size
- set_fontstyle(self, fontstyle)
- alias for set_style
- set_fontweight(self, weight)
- alias for set_weight
- set_ha(self, align)
- alias for set_horizontalalignment
- set_horizontalalignment(self, align)
- Set the horizontal alignment to one of
ACCEPTS: [ 'center' | 'right' | 'left' ]
- set_ma(self, align)
- alias for set_verticalalignment
- set_multialignment(self, align)
- Set the alignment for multiple lines layout. The layout of the
bounding box of all the lines is determined bu the horizontalalignment
and verticalalignment properties, but the multiline text within that
box can be
ACCEPTS: ['left' | 'right' | 'center' ]
- set_name(self, fontname)
- Set the font name,
ACCEPTS: string eg, ['Sans' | 'Courier' | 'Helvetica' ...]
- set_rotation(self, s)
- Set the rotation of the text
ACCEPTS: [ angle in degrees 'vertical' | 'horizontal'
- set_size(self, fontsize)
- Set the font size, eg, 8, 10, 12, 14...
ACCEPTS: [ size in points | relative size eg 'smaller', 'x-large' ]
- set_style(self, fontstyle)
- Set the font style
ACCEPTS: [ 'normal' | 'italic' | 'oblique']
- set_text(self, s)
- Set the text string s
ACCEPTS: string
- set_va(self, align)
- alias for set_verticalalignment
- set_variant(self, variant)
- Set the font variant, eg,
ACCEPTS: [ 'normal' | 'small-caps' ]
- set_verticalalignment(self, align)
- Set the vertical alignment
ACCEPTS: [ 'center' | 'top' | 'bottom' ]
- set_weight(self, weight)
- Set the font weight
ACCEPTS: [ 'normal' | 'bold' | 'heavy' | 'light' | 'ultrabold' | 'ultralight']
- update_from(self, other)
- Copy properties from other to self
Data and other attributes inherited from Text:
- zorder = 3
Methods inherited from matplotlib.artist.Artist:
- add_callback(self, func)
- get_alpha(self)
- Return the alpha value used for blending - not supported on all
backends
- get_animated(self)
- return the artist's animated state
- get_clip_box(self)
- Return artist clipbox
- get_clip_on(self)
- Return whether artist uses clipping
- get_label(self)
- get_transform(self)
- return the Transformation instance used by this artist
- get_visible(self)
- return the artist's visiblity
- get_zorder(self)
- is_figure_set(self)
- is_transform_set(self)
- Artist has transform explicity let
- pchanged(self)
- fire event when property changed
- remove_callback(self, oid)
- set(self, **kwargs)
- A tkstyle set command, pass kwargs to set properties
- set_alpha(self, alpha)
- Set the alpha value used for blending - not supported on
all backends
ACCEPTS: float
- set_animated(self, b)
- set the artist's animation state
ACCEPTS: [True | False]
- set_clip_box(self, clipbox)
- Set the artist's clip Bbox
ACCEPTS: a matplotlib.transform.Bbox instance
- set_clip_on(self, b)
- Set whether artist uses clipping
ACCEPTS: [True | False]
- set_label(self, s)
- Set the line label to s for auto legend
ACCEPTS: any string
- set_lod(self, on)
- Set Level of Detail on or off. If on, the artists may examine
things like the pixel width of the axes and draw a subset of
their contents accordingly
ACCEPTS: [True | False]
- set_visible(self, b)
- set the artist's visiblity
ACCEPTS: [True | False]
- set_zorder(self, level)
- Set the zorder for the artist
ACCEPTS: any number
- update(self, props)
Data and other attributes inherited from matplotlib.artist.Artist:
- aname = 'Artist'
| |