1
1
"""
2
2
Abstract base classes define the primitives that renderers and
3
- graphics contexts must implement to serve as a matplotlib backend
3
+ graphics contexts must implement to serve as a Matplotlib backend.
4
4
5
- :class: `RendererBase`
5
+ `RendererBase`
6
6
An abstract base class to handle drawing/rendering operations.
7
7
8
- :class:`FigureCanvasBase`
9
- The abstraction layer that separates the
10
- :class:`matplotlib.figure.Figure` from the backend specific
11
- details like a user interface drawing area
8
+ `FigureCanvasBase`
9
+ The abstraction layer that separates the `.Figure` from the backend
10
+ specific details like a user interface drawing area.
12
11
13
- :class: `GraphicsContextBase`
14
- An abstract base class that provides color, line styles, etc...
12
+ `GraphicsContextBase`
13
+ An abstract base class that provides color, line styles, etc.
15
14
16
- :class:`Event`
17
- The base class for all of the matplotlib event
18
- handling. Derived classes such as :class:`KeyEvent` and
19
- :class:`MouseEvent` store the meta data like keys and buttons
20
- pressed, x and y locations in pixel and
21
- :class:`~matplotlib.axes.Axes` coordinates.
15
+ `Event`
16
+ The base class for all of the Matplotlib event handling. Derived classes
17
+ such as `KeyEvent` and `MouseEvent` store the meta data like keys and
18
+ buttons pressed, x and y locations in pixel and `~.axes.Axes` coordinates.
22
19
23
- :class:`ShowBase`
24
- The base class for the Show class of each interactive backend;
25
- the 'show' callable is then set to Show.__call__, inherited from
26
- ShowBase.
20
+ `ShowBase`
21
+ The base class for the ``Show`` class of each interactive backend; the
22
+ 'show' callable is then set to ``Show.__call__``.
27
23
28
- :class: `ToolContainerBase`
29
- The base class for the Toolbar class of each interactive backend.
24
+ `ToolContainerBase`
25
+ The base class for the Toolbar class of each interactive backend.
30
26
31
- :class: `StatusbarBase`
27
+ `StatusbarBase`
32
28
The base class for the messaging area.
33
29
"""
34
30
@@ -470,13 +466,13 @@ def draw_image(self, gc, x, y, im, transform=None):
470
466
transform : `matplotlib.transforms.Affine2DBase`
471
467
If and only if the concrete backend is written such that
472
468
:meth:`option_scale_image` returns ``True``, an affine
473
- transformation *may* be passed to :meth:`draw_image`. It takes the
474
- form of a :class:`~matplotlib.transforms.Affine2DBase` instance.
475
- The translation vector of the transformation is given in physical
476
- units (i.e., dots or pixels). Note that the transformation does not
477
- override *x* and *y*, and has to be applied *before* translating
478
- the result by *x* and *y* (this can be accomplished by adding *x*
479
- and *y* to the translation vector defined by *transform*).
469
+ transformation (i.e., an `.Affine2DBase`) *may* be passed to
470
+ :meth:`draw_image`. The translation vector of the transformation
471
+ is given in physical units (i.e., dots or pixels). Note that
472
+ the transformation does not override *x* and *y*, and has to be
473
+ applied *before* translating the result by *x* and *y* (this can
474
+ be accomplished by adding *x* and *y* to the translation vector
475
+ defined by *transform*).
480
476
"""
481
477
raise NotImplementedError
482
478
@@ -584,7 +580,7 @@ def _draw_text_as_path(self, gc, x, y, s, prop, angle, ismath):
584
580
s : str
585
581
The text to be converted.
586
582
usetex : bool
587
- Whether to use matplotlib usetex mode.
583
+ Whether to use usetex mode.
588
584
ismath : bool or "TeX"
589
585
If True, use mathtext parser. If "TeX", use *usetex* mode.
590
586
"""
@@ -598,7 +594,7 @@ def get_text_width_height_descent(self, s, prop, ismath):
598
594
"""
599
595
Get the width, height, and descent (offset from the bottom
600
596
to the baseline), in display coords, of the string *s* with
601
- :class:`~matplotlib.font_manager. FontProperties` *prop*
597
+ `. FontProperties` *prop*.
602
598
"""
603
599
if ismath == 'TeX' :
604
600
# todo: handle props
@@ -782,7 +778,7 @@ def get_clip_rectangle(self):
782
778
def get_clip_path (self ):
783
779
"""
784
780
Return the clip path in the form (path, transform), where path
785
- is a :class:`~matplotlib .path.Path` instance, and transform is
781
+ is a `~ .path.Path` instance, and transform is
786
782
an affine transform to apply to the path before clipping.
787
783
"""
788
784
if self ._clippath is not None :
@@ -1191,21 +1187,18 @@ def _on_timer(self):
1191
1187
1192
1188
class Event :
1193
1189
"""
1194
- A matplotlib event. Attach additional attributes as defined in
1190
+ A Matplotlib event. Attach additional attributes as defined in
1195
1191
:meth:`FigureCanvasBase.mpl_connect`. The following attributes
1196
1192
are defined and shown with their default values
1197
1193
1198
1194
Attributes
1199
1195
----------
1200
1196
name : str
1201
- the event name
1202
-
1197
+ The event name.
1203
1198
canvas : `FigureCanvasBase`
1204
- the backend-specific canvas instance generating the event
1205
-
1199
+ The backend-specific canvas instance generating the event.
1206
1200
guiEvent
1207
- the GUI event that triggered the matplotlib event
1208
-
1201
+ The GUI event that triggered the Matplotlib event.
1209
1202
"""
1210
1203
def __init__ (self , name , canvas , guiEvent = None ):
1211
1204
self .name = name
@@ -1227,14 +1220,13 @@ class DrawEvent(Event):
1227
1220
Calling ``canvas.draw`` and ``canvas.blit`` in these callbacks may
1228
1221
not be safe with all backends and may cause infinite recursion.
1229
1222
1230
- In addition to the :class: `Event` attributes, the following event
1223
+ In addition to the `Event` attributes, the following event
1231
1224
attributes are defined:
1232
1225
1233
1226
Attributes
1234
1227
----------
1235
1228
renderer : `RendererBase`
1236
- the renderer for the draw event
1237
-
1229
+ The renderer for the draw event.
1238
1230
"""
1239
1231
def __init__ (self , name , canvas , renderer ):
1240
1232
Event .__init__ (self , name , canvas )
@@ -1245,17 +1237,15 @@ class ResizeEvent(Event):
1245
1237
"""
1246
1238
An event triggered by a canvas resize
1247
1239
1248
- In addition to the :class: `Event` attributes, the following event
1240
+ In addition to the `Event` attributes, the following event
1249
1241
attributes are defined:
1250
1242
1251
1243
Attributes
1252
1244
----------
1253
1245
width : scalar
1254
- width of the canvas in pixels
1255
-
1246
+ Width of the canvas in pixels.
1256
1247
height : scalar
1257
- height of the canvas in pixels
1258
-
1248
+ Height of the canvas in pixels.
1259
1249
"""
1260
1250
def __init__ (self , name , canvas ):
1261
1251
Event .__init__ (self , name , canvas )
@@ -1273,25 +1263,21 @@ class LocationEvent(Event):
1273
1263
The following additional attributes are defined and shown with
1274
1264
their default values.
1275
1265
1276
- In addition to the :class: `Event` attributes, the following
1266
+ In addition to the `Event` attributes, the following
1277
1267
event attributes are defined:
1278
1268
1279
1269
Attributes
1280
1270
----------
1281
1271
x : scalar
1282
- x position - pixels from left of canvas
1283
-
1272
+ x position - pixels from left of canvas.
1284
1273
y : scalar
1285
- y position - pixels from bottom of canvas
1286
-
1287
- inaxes : bool
1288
- the :class:`~matplotlib.axes.Axes` instance if mouse is over axes
1289
-
1290
- xdata : scalar
1291
- x coord of mouse in data coords
1292
-
1293
- ydata : scalar
1294
- y coord of mouse in data coords
1274
+ y position - pixels from bottom of canvas.
1275
+ inaxes : `~.axes.Axes` or None
1276
+ The `~.axes.Axes` instance over which the mouse is, if any.
1277
+ xdata : float or None
1278
+ x data coordinate of the mouse.
1279
+ ydata : float or None
1280
+ y data coordinate of the mouse.
1295
1281
"""
1296
1282
1297
1283
lastevent = None # the last event that was triggered before this one
@@ -1373,13 +1359,12 @@ class MouseEvent(LocationEvent):
1373
1359
'scroll_event',
1374
1360
'motion_notify_event').
1375
1361
1376
- In addition to the :class: `Event` and :class: `LocationEvent`
1362
+ In addition to the `Event` and `LocationEvent`
1377
1363
attributes, the following attributes are defined:
1378
1364
1379
1365
Attributes
1380
1366
----------
1381
- button : {None, MouseButton.LEFT, MouseButton.MIDDLE, MouseButton.RIGHT, \
1382
- 'up', 'down'}
1367
+ button : None or `MouseButton` or {'up', 'down'}
1383
1368
The button pressed. 'up' and 'down' are used for scroll events.
1384
1369
Note that in the nbagg backend, both the middle and right clicks
1385
1370
return RIGHT since right clicking will bring up the context menu in
@@ -1437,21 +1422,18 @@ class PickEvent(Event):
1437
1422
A pick event, fired when the user picks a location on the canvas
1438
1423
sufficiently close to an artist.
1439
1424
1440
- Attrs: all the :class: `Event` attributes plus
1425
+ Attrs: all the `Event` attributes plus
1441
1426
1442
1427
Attributes
1443
1428
----------
1444
1429
mouseevent : `MouseEvent`
1445
- the mouse event that generated the pick
1446
-
1430
+ The mouse event that generated the pick.
1447
1431
artist : `matplotlib.artist.Artist`
1448
- the picked artist
1449
-
1432
+ The picked artist.
1450
1433
other
1451
- extra class dependent attrs -- e.g., a
1452
- :class:`~matplotlib.lines.Line2D` pick may define different
1453
- extra attributes than a
1454
- :class:`~matplotlib.collections.PatchCollection` pick event
1434
+ Additional attributes may be present depending on the type of the
1435
+ picked object; e.g., a `~.Line2D` pick may define different extra
1436
+ attributes than a `~.PatchCollection` pick.
1455
1437
1456
1438
Examples
1457
1439
--------
@@ -1483,7 +1465,7 @@ class KeyEvent(LocationEvent):
1483
1465
Attach additional attributes as defined in
1484
1466
:meth:`FigureCanvasBase.mpl_connect`.
1485
1467
1486
- In addition to the :class: `Event` and :class: `LocationEvent`
1468
+ In addition to the `Event` and `LocationEvent`
1487
1469
attributes, the following attributes are defined:
1488
1470
1489
1471
Attributes
@@ -1556,7 +1538,7 @@ class FigureCanvasBase:
1556
1538
Attributes
1557
1539
----------
1558
1540
figure : `matplotlib.figure.Figure`
1559
- A high-level figure instance
1541
+ A high-level figure instance.
1560
1542
"""
1561
1543
1562
1544
# Set to one of {"qt5", "qt4", "gtk3", "wx", "tk", "macosx"} if an
@@ -1714,7 +1696,7 @@ def pick_event(self, mouseevent, artist, **kwargs):
1714
1696
Callback processing for pick events.
1715
1697
1716
1698
This method will be called by artists who are picked and will
1717
- fire off :class: `PickEvent` callbacks registered listeners.
1699
+ fire off `PickEvent` callbacks registered listeners.
1718
1700
"""
1719
1701
s = 'pick_event'
1720
1702
event = PickEvent (s , self , mouseevent , artist ,
@@ -1728,10 +1710,10 @@ def scroll_event(self, x, y, step, guiEvent=None):
1728
1710
1729
1711
Backend derived classes should call this function on any
1730
1712
scroll wheel event. (*x*, *y*) are the canvas coords ((0, 0) is lower
1731
- left). button and key are as defined in MouseEvent.
1713
+ left). button and key are as defined in ` MouseEvent` .
1732
1714
1733
- This method will be call all functions connected to the
1734
- 'scroll_event' with a :class: `MouseEvent` instance.
1715
+ This method will callall functions connected to the 'scroll_event' with
1716
+ a `MouseEvent` instance.
1735
1717
"""
1736
1718
if step >= 0 :
1737
1719
self ._button = 'up'
@@ -1748,10 +1730,10 @@ def button_press_event(self, x, y, button, dblclick=False, guiEvent=None):
1748
1730
1749
1731
Backend derived classes should call this function on any mouse
1750
1732
button press. (*x*, *y*) are the canvas coords ((0, 0) is lower left).
1751
- button and key are as defined in :class: `MouseEvent`.
1733
+ button and key are as defined in `MouseEvent`.
1752
1734
1753
- This method will be call all functions connected to the
1754
- 'button_press_event' with a :class: `MouseEvent` instance.
1735
+ This method will callall functions connected to the
1736
+ 'button_press_event' with a `MouseEvent` instance.
1755
1737
"""
1756
1738
self ._button = button
1757
1739
s = 'button_press_event'
@@ -1767,7 +1749,7 @@ def button_release_event(self, x, y, button, guiEvent=None):
1767
1749
button release.
1768
1750
1769
1751
This method will call all functions connected to the
1770
- 'button_release_event' with a :class: `MouseEvent` instance.
1752
+ 'button_release_event' with a `MouseEvent` instance.
1771
1753
1772
1754
Parameters
1773
1755
----------
@@ -1791,7 +1773,7 @@ def motion_notify_event(self, x, y, guiEvent=None):
1791
1773
motion-notify-event.
1792
1774
1793
1775
This method will call all functions connected to the
1794
- 'motion_notify_event' with a :class: `MouseEvent` instance.
1776
+ 'motion_notify_event' with a `MouseEvent` instance.
1795
1777
1796
1778
Parameters
1797
1779
----------
@@ -1897,7 +1879,7 @@ def release_mouse(self, ax):
1897
1879
self .mouse_grabber = None
1898
1880
1899
1881
def draw (self , * args , ** kwargs ):
1900
- """Render the :class:`~matplotlib.figure .Figure`."""
1882
+ """Render the ` .Figure`."""
1901
1883
1902
1884
def draw_idle (self , * args , ** kwargs ):
1903
1885
"""
@@ -2313,11 +2295,11 @@ def key_press_handler(event, canvas, toolbar=None):
2313
2295
2314
2296
Parameters
2315
2297
----------
2316
- event : :class: `KeyEvent`
2298
+ event : `KeyEvent`
2317
2299
a key press/release event
2318
- canvas : :class: `FigureCanvasBase`
2300
+ canvas : `FigureCanvasBase`
2319
2301
the backend-specific canvas instance
2320
- toolbar : :class: `NavigationToolbar2`
2302
+ toolbar : `NavigationToolbar2`
2321
2303
the navigation cursor toolbar
2322
2304
"""
2323
2305
# these bindings happen whether you are over an axes or not
@@ -2527,7 +2509,7 @@ class FigureManagerBase:
2527
2509
2528
2510
Attributes
2529
2511
----------
2530
- canvas : :class: `FigureCanvasBase`
2512
+ canvas : `FigureCanvasBase`
2531
2513
The backend-specific canvas instance.
2532
2514
2533
2515
num : int or str
0 commit comments