| |
- matplotlib.artist.Artist(__builtin__.object)
-
- Text
-
- Annotation
- TextWithDash
class Annotation(Text) |
|
A :class:`~matplotlib.text.Text` class to make annotating things
in the figure, such as :class:`~matplotlib.figure.Figure`,
:class:`~matplotlib.axes.Axes`,
:class:`~matplotlib.patches.Rectangle`, etc., easier. |
|
- Method resolution order:
- Annotation
- Text
- matplotlib.artist.Artist
- __builtin__.object
Methods defined here:
- __init__(self, s, xy, xytext=None, xycoords='data', textcoords=None, arrowprops=None, **kwargs)
- Annotate the *x*, *y* point *xy* with text *s* at *x*, *y*
location *xytext*. (If *xytext* = *None*, defaults to *xy*,
and if *textcoords* = *None*, defaults to *xycoords*).
*arrowprops*, if not *None*, is a dictionary of line properties
(see :class:`matplotlib.lines.Line2D`) for the arrow that connects
annotation to the point. Valid keys are
========= ===========================================================
Key Description
========= ===========================================================
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 oftentimes 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 :class:`matplotlib.patches.polygon`
========= ===========================================================
*xycoords* and *textcoords* are strings that indicate the
coordinates of *xy* and *xytext*.
================= ===================================================
Property Description
================= ===================================================
'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)
'offset points' Specify an offset (in points) from the *xy* value
'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 bottom-left 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'
Additional kwargs are Text properties:
========================= =====================================================================
Property Description
========================= =====================================================================
alpha float
animated [True | False]
axes an axes instance
backgroundcolor any matplotlib color
bbox rectangle prop dict plus key 'pad' which is a pad in points
clip_box a :class:`matplotlib.transform.Bbox` instance
clip_on [True | False]
clip_path a :class:`~matplotlib.path.Path` instance and a
color any matplotlib color
contains unknown
family [ 'serif' | 'sans-serif' | 'cursive' | 'fantasy' | 'monospace' ]
figure a :class:`matplotlib.figure.Figure` instance
fontproperties a matplotlib.font_manager.FontProperties instance
horizontalalignment or ha [ 'center' | 'right' | 'left' ]
label any string
linespacing float
lod [True | False]
multialignment ['left' | 'right' | 'center' ]
name or fontname string eg, ['Sans' | 'Courier' | 'Helvetica' ...]
picker [None|float|boolean|callable]
position (x,y)
rotation [ angle in degrees 'vertical' | 'horizontal'
size or fontsize [ size in points | relative size eg 'smaller', 'x-large' ]
style or fontstyle [ 'normal' | 'italic' | 'oblique']
text string or anything printable with '%s' conversion
transform unknown
variant [ 'normal' | 'small-caps' ]
verticalalignment or va [ 'center' | 'top' | 'bottom' | 'baseline' ]
visible [True | False]
weight or fontweight [ 'normal' | 'bold' | 'heavy' | 'light' | 'ultrabold' | 'ultralight']
x float
y float
zorder any number
========================= =====================================================================
- __str__(self)
- contains(self, event)
- draw(self, renderer)
- set_clip_box(self, clipbox)
- Set the artist's clip Bbox
ACCEPTS: a matplotlib.transform.Bbox instance
- set_figure(self, fig)
- 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_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, s)
- set_backgroundcolor(self, color)
- Set the background color of the text by updating the bbox (see set_bbox for more info)
ACCEPTS: any matplotlib color
- set_bbox(self, rectprops)
- Draw a bounding box around self. rect props are any settable
properties for a rectangle, eg facecolor='red', alpha=0.5.
t.set_bbox(dict(facecolor='red', 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_linespacing(self, spacing)
- Set the line spacing as a multiple of the font size.
Default is 1.2.
ACCEPTS: float
- 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 or anything printable with '%s' conversion
- 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' | 'baseline' ]
- 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)
- convert_xunits(self, x)
- for artists in an axes, if the xaxis as units support,
convert *x* using xaxis unit type
- convert_yunits(self, y)
- for artists in an axes, if the yaxis as units support,
convert *y* using yaxis unit type
- findobj(self, match=None)
- pyplot signature:
findobj(o=gcf(), match=None)
recursively find all :class:matplotlib.artist.Artist instances
contained in self
*match* can be
- None: return all objects contained in artist (including artist)
- function with signature ``boolean = match(artist)`` used to filter matches
- class instance: eg Line2D. Only return artists of class type
.. plot:: ../mpl_examples/pylab_examples/findobj_demo.py
- 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_axes(self)
- return the axes instance the artist resides in, or *None*
- get_clip_box(self)
- Return artist clipbox
- get_clip_on(self)
- Return whether artist uses clipping
- get_clip_path(self)
- Return artist clip path
- get_contains(self)
- return the _contains test used by the artist, or *None* for default.
- get_figure(self)
- Return the :class:`~matplotlib.figure.Figure` instance the
artist belongs to.
- get_label(self)
- get_picker(self)
- return the Pickeration instance used by this artist
- get_transform(self)
- Return the :class:`~matplotlib.transforms.Transform`
instance used by this artist.
- get_transformed_clip_path_and_affine(self)
- Return the clip path with the non-affine part of its
transformation applied, and the remaining affine part of its
transformation.
- get_visible(self)
- return the artist's visiblity
- get_zorder(self)
- have_units(self)
- return *True* if units are set on the x or y axes
- hitlist(self, event)
- List the children of the artist which contain the mouse event
- is_figure_set(self)
- is_transform_set(self)
- Artist has transform explicity let
- pchanged(self)
- fire event when property changed
- pick(self, mouseevent)
- call signature::
pick(mouseevent)
each child artist will fire a pick event if *mouseevent* is over
the artist and the artist has picker set
- pickable(self)
- return *True* if self is pickable
- remove(self)
- Remove the artist from the figure if possible. The effect
will not be visible until the figure is redrawn, e.g., with
:meth:`matplotlib.axes.Axes.draw_idle`. Call
:meth:`matplotlib.axes.Axes.relim` to update the axes limits
if desired.
Note: :meth:`~matplotlib.axes.Axes.relim` will not see
collections even if the collection was added to axes with
*autolim* = True.
Note: there is no support for removing the artist's legend entry.
- 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_axes(self, axes)
- set the axes instance in which the artist resides, if any
ACCEPTS: an axes instance
- set_clip_on(self, b)
- Set whether artist uses clipping
ACCEPTS: [True | False]
- set_clip_path(self, path, transform=None)
- Set the artist's clip path, which may be:
* a :class:`~matplotlib.patches.Patch` (or subclass) instance
* a :class:`~matplotlib.path.Path` instance, in which case
an optional :class:`~matplotlib.transforms.Transform`
instance may be provided, which will be applied to the
path before using it for clipping.
* *None*, to remove the clipping path
For efficiency, if the path happens to be an axis-aligned
rectangle, this method will set the clipping box to the
corresponding rectangle and set the clipping path to *None*.
ACCEPTS: a :class:`~matplotlib.path.Path` instance and a
:class:`~matplotlib.transforms.Transform` instance, a
:class:`~matplotlib.patches.Patch` instance, or *None*.
- set_contains(self, picker)
- Replace the contains test used by this artist. The new picker should
be a callable function which determines whether the artist is hit by the
mouse event::
hit, props = picker(artist, mouseevent)
If the mouse event is over the artist, return *hit=True* and *props*
is a dictionary of properties you want returned with the contains test.
- 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_picker(self, picker)
- set the epsilon for picking used by this artist
*picker* can be one of the following:
* *None*: picking is disabled for this artist (default)
* A boolean: if *True* then picking will be enabled and the
artist will fire a pick event if the mouse event is over
the artist
* A float: if picker is a number it is interpreted as an
epsilon tolerance in points and the artist will fire
off an event if it's data is within epsilon of the mouse
event. For some artists like lines and patch collections,
the artist may provide additional data to the pick event
that is generated, e.g. the indices of the data within
epsilon of the pick event
* A function: if picker is callable, it is a user supplied
function which determines whether the artist is hit by the
mouse event::
hit, props = picker(artist, mouseevent)
to determine the hit test. if the mouse event is over the
artist, return *hit=True* and props is a dictionary of
properties you want added to the PickEvent attributes.
ACCEPTS: [None|float|boolean|callable]
- set_transform(self, t)
- Set the :class:`~matplotlib.transforms.Transform` instance
used by this artist.
- 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 descriptors inherited from matplotlib.artist.Artist:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
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 |
|
- Method resolution order:
- Text
- matplotlib.artist.Artist
- __builtin__.object
Methods defined here:
- __init__(self, x=0, y=0, text='', color=None, verticalalignment='bottom', horizontalalignment='left', multialignment=None, fontproperties=None, rotation=None, linespacing=None, **kwargs)
- Create a :class:`~matplotlib.text.Text` instance at *x*, *y*
with string *text*.
Valid kwargs are
========================== =========================================================================
alpha float
========================== =========================================================================
animated [True | False]
backgroundcolor any matplotlib color
bbox rectangle prop dict plus key 'pad' which is a pad in points
clip_box a matplotlib.transform.Bbox instance
clip_on [True | False]
color any matplotlib color
family [ 'serif' | 'sans-serif' | 'cursive' | 'fantasy' | 'monospace' ]
figure a matplotlib.figure.Figure instance
fontproperties a matplotlib.font_manager.FontProperties instance
horizontalalignment or ha [ 'center' | 'right' | 'left' ]
label any string
linespacing float
lod [True | False]
multialignment ['left' | 'right' | 'center' ]
name or fontname string eg, ['Sans' | 'Courier' | 'Helvetica' ...]
position (x,y)
rotation [ angle in degrees 'vertical' | 'horizontal'
size or fontsize [ size in points | relative size eg 'smaller', 'x-large' ]
style or fontstyle [ 'normal' | 'italic' | 'oblique']
text string
transform a matplotlib.transform transformation instance
variant [ 'normal' | 'small-caps' ]
verticalalignment or va [ 'center' | 'top' | 'bottom' | 'baseline' ]
visible [True | False]
weight or fontweight [ 'normal' | 'bold' | 'heavy' | 'light' | 'ultrabold' | 'ultralight']
x float
y float
zorder any number
========================== =========================================================================
- __str__(self)
- contains(self, mouseevent)
- Test whether the mouse event occurred in the patch.
Returns T/F, {}
- 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_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, s)
- set_backgroundcolor(self, color)
- Set the background color of the text by updating the bbox (see set_bbox for more info)
ACCEPTS: any matplotlib color
- set_bbox(self, rectprops)
- Draw a bounding box around self. rect props are any settable
properties for a rectangle, eg facecolor='red', alpha=0.5.
t.set_bbox(dict(facecolor='red', 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_linespacing(self, spacing)
- Set the line spacing as a multiple of the font size.
Default is 1.2.
ACCEPTS: float
- 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 or anything printable with '%s' conversion
- 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' | 'baseline' ]
- 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)
- convert_xunits(self, x)
- for artists in an axes, if the xaxis as units support,
convert *x* using xaxis unit type
- convert_yunits(self, y)
- for artists in an axes, if the yaxis as units support,
convert *y* using yaxis unit type
- findobj(self, match=None)
- pyplot signature:
findobj(o=gcf(), match=None)
recursively find all :class:matplotlib.artist.Artist instances
contained in self
*match* can be
- None: return all objects contained in artist (including artist)
- function with signature ``boolean = match(artist)`` used to filter matches
- class instance: eg Line2D. Only return artists of class type
.. plot:: ../mpl_examples/pylab_examples/findobj_demo.py
- 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_axes(self)
- return the axes instance the artist resides in, or *None*
- get_clip_box(self)
- Return artist clipbox
- get_clip_on(self)
- Return whether artist uses clipping
- get_clip_path(self)
- Return artist clip path
- get_contains(self)
- return the _contains test used by the artist, or *None* for default.
- get_figure(self)
- Return the :class:`~matplotlib.figure.Figure` instance the
artist belongs to.
- get_label(self)
- get_picker(self)
- return the Pickeration instance used by this artist
- get_transform(self)
- Return the :class:`~matplotlib.transforms.Transform`
instance used by this artist.
- get_transformed_clip_path_and_affine(self)
- Return the clip path with the non-affine part of its
transformation applied, and the remaining affine part of its
transformation.
- get_visible(self)
- return the artist's visiblity
- get_zorder(self)
- have_units(self)
- return *True* if units are set on the x or y axes
- hitlist(self, event)
- List the children of the artist which contain the mouse event
- is_figure_set(self)
- is_transform_set(self)
- Artist has transform explicity let
- pchanged(self)
- fire event when property changed
- pick(self, mouseevent)
- call signature::
pick(mouseevent)
each child artist will fire a pick event if *mouseevent* is over
the artist and the artist has picker set
- pickable(self)
- return *True* if self is pickable
- remove(self)
- Remove the artist from the figure if possible. The effect
will not be visible until the figure is redrawn, e.g., with
:meth:`matplotlib.axes.Axes.draw_idle`. Call
:meth:`matplotlib.axes.Axes.relim` to update the axes limits
if desired.
Note: :meth:`~matplotlib.axes.Axes.relim` will not see
collections even if the collection was added to axes with
*autolim* = True.
Note: there is no support for removing the artist's legend entry.
- 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_axes(self, axes)
- set the axes instance in which the artist resides, if any
ACCEPTS: an axes instance
- set_clip_box(self, clipbox)
- Set the artist's clip Bbox
ACCEPTS: a :class:`matplotlib.transform.Bbox` instance
- set_clip_on(self, b)
- Set whether artist uses clipping
ACCEPTS: [True | False]
- set_clip_path(self, path, transform=None)
- Set the artist's clip path, which may be:
* a :class:`~matplotlib.patches.Patch` (or subclass) instance
* a :class:`~matplotlib.path.Path` instance, in which case
an optional :class:`~matplotlib.transforms.Transform`
instance may be provided, which will be applied to the
path before using it for clipping.
* *None*, to remove the clipping path
For efficiency, if the path happens to be an axis-aligned
rectangle, this method will set the clipping box to the
corresponding rectangle and set the clipping path to *None*.
ACCEPTS: a :class:`~matplotlib.path.Path` instance and a
:class:`~matplotlib.transforms.Transform` instance, a
:class:`~matplotlib.patches.Patch` instance, or *None*.
- set_contains(self, picker)
- Replace the contains test used by this artist. The new picker should
be a callable function which determines whether the artist is hit by the
mouse event::
hit, props = picker(artist, mouseevent)
If the mouse event is over the artist, return *hit=True* and *props*
is a dictionary of properties you want returned with the contains test.
- set_figure(self, fig)
- Set the :class:`~matplotlib.figure.Figure` instance the artist
belongs to.
ACCEPTS: a :class:`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_picker(self, picker)
- set the epsilon for picking used by this artist
*picker* can be one of the following:
* *None*: picking is disabled for this artist (default)
* A boolean: if *True* then picking will be enabled and the
artist will fire a pick event if the mouse event is over
the artist
* A float: if picker is a number it is interpreted as an
epsilon tolerance in points and the artist will fire
off an event if it's data is within epsilon of the mouse
event. For some artists like lines and patch collections,
the artist may provide additional data to the pick event
that is generated, e.g. the indices of the data within
epsilon of the pick event
* A function: if picker is callable, it is a user supplied
function which determines whether the artist is hit by the
mouse event::
hit, props = picker(artist, mouseevent)
to determine the hit test. if the mouse event is over the
artist, return *hit=True* and props is a dictionary of
properties you want added to the PickEvent attributes.
ACCEPTS: [None|float|boolean|callable]
- set_transform(self, t)
- Set the :class:`~matplotlib.transforms.Transform` instance
used by this artist.
- 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 descriptors inherited from matplotlib.artist.Artist:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
Data and other attributes inherited from matplotlib.artist.Artist:
- aname = 'Artist'
|
class TextWithDash(Text) |
|
This is basically a :class:`~matplotlib.text.Text` with a dash
(drawn with a :class:`~matplotlib.lines.Line2D`) before/after
it. It is intended to be a drop-in replacement for
:class:`~matplotlib.text.Text`, and should behave identically to
it when *dashlength* = 0.0.
The dash always comes between the point specified by
:meth:`~matplotlib.text.Text.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
:meth:`~matplotlib.text.TextWithDash.get_dashrotation` returns
:meth:`~matplotlib.text.Text.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 :meth:`~matplotlib.text.Text.set_position` by the
amount in canvas units. (default = 0)
*NOTE*: The alignment of the two objects is based on the bounding
box of the :class:`~matplotlib.text.Text`, as obtained by
:meth:`~matplotlib.artist.Artist.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.
*NOTE 2*: I'm not sure that I got the
:meth:`~matplotlib.text.TextWithDash.get_window_extent` right, or
whether that's sufficient for providing the object bounding box. |
|
- Method resolution order:
- TextWithDash
- Text
- matplotlib.artist.Artist
- __builtin__.object
Methods defined here:
- __init__(self, x=0, y=0, text='', color=None, verticalalignment='center', horizontalalignment='center', multialignment=None, fontproperties=None, rotation=None, linespacing=None, dashlength=0.0, dashdirection=0, dashrotation=None, dashpad=3, dashpush=0, xaxis=True)
- __str__(self)
- 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_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_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:
- contains(self, mouseevent)
- Test whether the mouse event occurred in the patch.
Returns T/F, {}
- 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_rotation(self)
- return the text angle as float
- 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, s)
- set_backgroundcolor(self, color)
- Set the background color of the text by updating the bbox (see set_bbox for more info)
ACCEPTS: any matplotlib color
- set_bbox(self, rectprops)
- Draw a bounding box around self. rect props are any settable
properties for a rectangle, eg facecolor='red', alpha=0.5.
t.set_bbox(dict(facecolor='red', 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_linespacing(self, spacing)
- Set the line spacing as a multiple of the font size.
Default is 1.2.
ACCEPTS: float
- 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 or anything printable with '%s' conversion
- 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' | 'baseline' ]
- 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)
- convert_xunits(self, x)
- for artists in an axes, if the xaxis as units support,
convert *x* using xaxis unit type
- convert_yunits(self, y)
- for artists in an axes, if the yaxis as units support,
convert *y* using yaxis unit type
- findobj(self, match=None)
- pyplot signature:
findobj(o=gcf(), match=None)
recursively find all :class:matplotlib.artist.Artist instances
contained in self
*match* can be
- None: return all objects contained in artist (including artist)
- function with signature ``boolean = match(artist)`` used to filter matches
- class instance: eg Line2D. Only return artists of class type
.. plot:: ../mpl_examples/pylab_examples/findobj_demo.py
- 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_axes(self)
- return the axes instance the artist resides in, or *None*
- get_clip_box(self)
- Return artist clipbox
- get_clip_on(self)
- Return whether artist uses clipping
- get_clip_path(self)
- Return artist clip path
- get_contains(self)
- return the _contains test used by the artist, or *None* for default.
- get_label(self)
- get_picker(self)
- return the Pickeration instance used by this artist
- get_transform(self)
- Return the :class:`~matplotlib.transforms.Transform`
instance used by this artist.
- get_transformed_clip_path_and_affine(self)
- Return the clip path with the non-affine part of its
transformation applied, and the remaining affine part of its
transformation.
- get_visible(self)
- return the artist's visiblity
- get_zorder(self)
- have_units(self)
- return *True* if units are set on the x or y axes
- hitlist(self, event)
- List the children of the artist which contain the mouse event
- is_figure_set(self)
- is_transform_set(self)
- Artist has transform explicity let
- pchanged(self)
- fire event when property changed
- pick(self, mouseevent)
- call signature::
pick(mouseevent)
each child artist will fire a pick event if *mouseevent* is over
the artist and the artist has picker set
- pickable(self)
- return *True* if self is pickable
- remove(self)
- Remove the artist from the figure if possible. The effect
will not be visible until the figure is redrawn, e.g., with
:meth:`matplotlib.axes.Axes.draw_idle`. Call
:meth:`matplotlib.axes.Axes.relim` to update the axes limits
if desired.
Note: :meth:`~matplotlib.axes.Axes.relim` will not see
collections even if the collection was added to axes with
*autolim* = True.
Note: there is no support for removing the artist's legend entry.
- 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_axes(self, axes)
- set the axes instance in which the artist resides, if any
ACCEPTS: an axes instance
- set_clip_box(self, clipbox)
- Set the artist's clip Bbox
ACCEPTS: a :class:`matplotlib.transform.Bbox` instance
- set_clip_on(self, b)
- Set whether artist uses clipping
ACCEPTS: [True | False]
- set_clip_path(self, path, transform=None)
- Set the artist's clip path, which may be:
* a :class:`~matplotlib.patches.Patch` (or subclass) instance
* a :class:`~matplotlib.path.Path` instance, in which case
an optional :class:`~matplotlib.transforms.Transform`
instance may be provided, which will be applied to the
path before using it for clipping.
* *None*, to remove the clipping path
For efficiency, if the path happens to be an axis-aligned
rectangle, this method will set the clipping box to the
corresponding rectangle and set the clipping path to *None*.
ACCEPTS: a :class:`~matplotlib.path.Path` instance and a
:class:`~matplotlib.transforms.Transform` instance, a
:class:`~matplotlib.patches.Patch` instance, or *None*.
- set_contains(self, picker)
- Replace the contains test used by this artist. The new picker should
be a callable function which determines whether the artist is hit by the
mouse event::
hit, props = picker(artist, mouseevent)
If the mouse event is over the artist, return *hit=True* and *props*
is a dictionary of properties you want returned with the contains test.
- 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_picker(self, picker)
- set the epsilon for picking used by this artist
*picker* can be one of the following:
* *None*: picking is disabled for this artist (default)
* A boolean: if *True* then picking will be enabled and the
artist will fire a pick event if the mouse event is over
the artist
* A float: if picker is a number it is interpreted as an
epsilon tolerance in points and the artist will fire
off an event if it's data is within epsilon of the mouse
event. For some artists like lines and patch collections,
the artist may provide additional data to the pick event
that is generated, e.g. the indices of the data within
epsilon of the pick event
* A function: if picker is callable, it is a user supplied
function which determines whether the artist is hit by the
mouse event::
hit, props = picker(artist, mouseevent)
to determine the hit test. if the mouse event is over the
artist, return *hit=True* and props is a dictionary of
properties you want added to the PickEvent attributes.
ACCEPTS: [None|float|boolean|callable]
- 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 descriptors inherited from matplotlib.artist.Artist:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
Data and other attributes inherited from matplotlib.artist.Artist:
- aname = 'Artist'
| |