| |
- matplotlib.artist.Artist
-
- Text
- TextWithDash
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)
- 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 - see help(colors)
- 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 - see help(colors)
- 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 t 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_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_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(matplotlib.artist.Artist) |
|
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 (implemented using delegation and get/setattr),
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. |
|
Methods defined here:
- __getattr__(self, name)
- Delegate most things to self._mytext.
- __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)
- __setattr__(self, name, value)
- Capture only a few things as necessary
and send the rest off to self._mytext
- 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
self._mytext 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 matplotlib.artist.Artist:
- add_callback(self, func)
- get_alpha(self)
- Return the alpha value used for blending - not supported on all
backends
- 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_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)
- update_from(self, other)
- copy properties from other to self
Data and other attributes inherited from matplotlib.artist.Artist:
- aname = 'Artist'
- zorder = 0
| |