Handle storing and drawing of text in window or data coordinates.
| 147 | "multialignment": ["ma"], |
| 148 | }) |
| 149 | class Text(Artist): |
| 150 | """Handle storing and drawing of text in window or data coordinates.""" |
| 151 | |
| 152 | zorder = 3 |
| 153 | _charsize_cache = dict() |
| 154 | |
| 155 | def __repr__(self): |
| 156 | return f"Text({self._x}, {self._y}, {self._text!r})" |
| 157 | |
| 158 | def __init__(self, |
| 159 | x=0, y=0, text='', *, |
| 160 | color=None, # defaults to rc params |
| 161 | verticalalignment='baseline', |
| 162 | horizontalalignment='left', |
| 163 | multialignment=None, |
| 164 | fontproperties=None, # defaults to FontProperties() |
| 165 | rotation=None, |
| 166 | linespacing=None, |
| 167 | rotation_mode=None, |
| 168 | usetex=None, # defaults to rcParams['text.usetex'] |
| 169 | wrap=False, |
| 170 | transform_rotates_text=False, |
| 171 | parse_math=None, # defaults to rcParams['text.parse_math'] |
| 172 | antialiased=None, # defaults to rcParams['text.antialiased'] |
| 173 | **kwargs |
| 174 | ): |
| 175 | """ |
| 176 | Create a `.Text` instance at *x*, *y* with string *text*. |
| 177 | |
| 178 | The text is aligned relative to the anchor point (*x*, *y*) according |
| 179 | to ``horizontalalignment`` (default: 'left') and ``verticalalignment`` |
| 180 | (default: 'baseline'). See also |
| 181 | :doc:`/gallery/text_labels_and_annotations/text_alignment`. |
| 182 | |
| 183 | While Text accepts the 'label' keyword argument, by default it is not |
| 184 | added to the handles of a legend. |
| 185 | |
| 186 | Valid keyword arguments are: |
| 187 | |
| 188 | %(Text:kwdoc)s |
| 189 | """ |
| 190 | super().__init__() |
| 191 | self._x, self._y = x, y |
| 192 | self._text = '' |
| 193 | self._features = None |
| 194 | self.set_language(None) |
| 195 | self._reset_visual_defaults( |
| 196 | text=text, |
| 197 | color=color, |
| 198 | fontproperties=fontproperties, |
| 199 | usetex=usetex, |
| 200 | parse_math=parse_math, |
| 201 | wrap=wrap, |
| 202 | verticalalignment=verticalalignment, |
| 203 | horizontalalignment=horizontalalignment, |
| 204 | multialignment=multialignment, |
| 205 | rotation=rotation, |
| 206 | transform_rotates_text=transform_rotates_text, |
no outgoing calls
searching dependent graphs…