• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

morganjwilliams / pyrolite / 17569160869

09 Sep 2025 01:41AM UTC coverage: 91.465% (-0.1%) from 91.614%
17569160869

push

github

morganjwilliams
Add uncertainties, add optional deps for pyproject.toml; WIP demo NB

6226 of 6807 relevant lines covered (91.46%)

10.97 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

94.12
/pyrolite/util/plot/legend.py
1
"""
2
Functions for creating and modifying legend entries for matplotlib.
3

4
Todo
5
------
6

7
    * Functions for working with and modifying legend entries.
8

9
        ax.lines + ax.patches + ax.collections + ax.containers, handle ax.parasites
10
"""
11

12
from copy import copy
12✔
13

14
import matplotlib.lines
12✔
15
import matplotlib.patches
12✔
16

17
from ..log import Handle
12✔
18

19
logger = Handle(__name__)
12✔
20

21

22
def proxy_rect(**kwargs):
12✔
23
    """
24
    Generates a legend proxy for a filled region.
25

26
    Returns
27
    ----------
28
    :class:`matplotlib.patches.Rectangle`
29
    """
30
    return matplotlib.patches.Rectangle((0, 0), 1, 1, **kwargs)
×
31

32

33
def proxy_line(**kwargs):
12✔
34
    """
35
    Generates a legend proxy for a line region.
36

37
    Returns
38
    ----------
39
    :class:`matplotlib.lines.Line2D`
40
    """
41
    return matplotlib.lines.Line2D(range(1), range(1), **kwargs)
12✔
42

43

44
def modify_legend_handles(ax, **kwargs):
12✔
45
    """
46
    Modify the handles of a legend based for a single axis.
47

48
    Parameters
49
    ----------
50
    ax : :class:`matplotlib.axes.Axes`
51
        Axis for which to obtain modifed legend handles.
52

53
    Returns
54
    -------
55
    handles : :class:`list`
56
        Handles to be passed to a legend call.
57
    labels : :class:`list`
58
        Labels to be passed to a legend call.
59
    """
60
    hndls, labls = ax.get_legend_handles_labels()
12✔
61
    _hndls = []
12✔
62
    for h in hndls:
12✔
63
        _h = copy(h)
12✔
64
        _h.update(kwargs)
12✔
65
        _hndls.append(_h)
12✔
66
    return _hndls, labls
12✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc