8000 Merge branch 'matplotlib:main' into bug-fix-issue-20243 · matplotlib/matplotlib@c5bea2f · GitHub
[go: up one dir, main page]

Skip to content

Commit c5bea2f

Browse files
Merge branch 'matplotlib:main' into bug-fix-issue-20243
2 parents e8d95d9 + 200808c commit c5bea2f

File tree

26 files changed

+361
-169
lines changed
  • axes
  • backends
  • mpl-data/stylelib
  • tests
  • 26 files changed

    +361
    -169
    lines changed

    .github/workflows/codeql-analysis.yml

    Lines changed: 2 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -31,7 +31,7 @@ jobs:
    3131
    persist-credentials: false
    3232

    < 6D40 /td>
    3333
    - name: Initialize CodeQL
    34-
    uses: github/codeql-action/init@60168efe1c415ce0f5521ea06d5c2062adbeed1b # v3.28.17
    34+
    uses: github/codeql-action/init@ff0a06e83cb2de871e5a09832bc6a81e7276941f # v3.28.18
    3535
    with:
    3636
    languages: ${{ matrix.language }}
    3737

    @@ -42,4 +42,4 @@ jobs:
    4242
    pip install --user -v .
    4343
    4444
    - name: Perform CodeQL Analysis
    45-
    uses: github/codeql-action/analyze@60168efe1c415ce0f5521ea06d5c2062adbeed1b # v3.28.17
    45+
    uses: github/codeql-action/analyze@ff0a06e83cb2de871e5a09832bc6a81e7276941f # v3.28.18

    .github/workflows/reviewdog.yml

    Lines changed: 14 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -6,6 +6,20 @@ permissions:
    66
    contents: read
    77

    88
    jobs:
    9+
    pre-commit:
    10+
    name: precommit
    11+
    runs-on: ubuntu-latest
    12+
    steps:
    13+
    - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
    14+
    with:
    15+
    fetch-depth: 0
    16+
    - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
    17+
    with:
    18+
    python-version: "3.x"
    19+
    - uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
    20+
    with:
    21+
    extra_args: --hook-stage manual --all-files
    22+
    923
    ruff:
    1024
    name: ruff
    1125
    runs-on: ubuntu-latest

    .github/workflows/tests.yml

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -396,7 +396,7 @@ jobs:
    396396
    fi
    397397
    - name: Upload code coverage
    398398
    if: ${{ !cancelled() && github.event_name != 'schedule' }}
    399-
    uses: codecov/codecov-action@ad3126e916f78f00edff4ed0317cf185271ccc2d # v5.4.2
    399+
    uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24 # v5.4.3
    400400
    with:
    401401
    name: "${{ matrix.python-version }} ${{ matrix.os }} ${{ matrix.name-suffix }}"
    402402
    token: ${{ secrets.CODECOV_TOKEN }}
    Lines changed: 2 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -1,3 +1,3 @@
    1-
    ``PdfFile.fontNames``, ``PdfFile.dviFontNames``, ``PdfFile.type1Descriptors``
    2-
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    1+
    ``PdfFile.fontNames``, ``PdfFile.dviFontInfo``, ``PdfFile.type1Descriptors``
    2+
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    33
    ... are deprecated with no replacement.
    Lines changed: 4 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -0,0 +1,4 @@
    1+
    ``backend_ps.get_bbox_header``
    2+
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    3+
    4+
    ... is removed, as it is considered an internal helper.
    Lines changed: 21 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -0,0 +1,21 @@
    1+
    Six and eight color Petroff color cycles
    2+
    ----------------------------------------
    3+
    4+
    The six and eight color accessible Petroff color cycles are named 'petroff6' and
    5+
    'petroff8'.
    6+
    They compliment the existing 'petroff10' color cycle, added in `Matplotlib 3.10.0`_
    7+
    8+
    For more details see
    9+
    `Petroff, M. A.: "Accessible Color Sequences for Data Visualization"
    10+
    <https://arxiv.org/abs/2107.02270>`_.
    11+
    To load the 'petroff6' color cycle in place of the default::
    12+
    13+
    import matplotlib.pyplot as plt
    14+
    plt.style.use('petroff6')
    15+
    16+
    or to load the 'petroff8' color cycle::
    17+
    18+
    import matplotlib.pyplot as plt
    19+
    plt.style.use('petroff8')
    20+
    21+
    .. _Matplotlib 3.10.0: https://matplotlib.org/stable/users/prev_whats_new/whats_new_3.10.0.html#new-more-accessible-color-cycle

    doc/users/resources/index.rst

    Lines changed: 4 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -82,6 +82,10 @@ Tutorials
    8282
    <https://github.com/stefmolin/python-data-viz-workshop>`_
    8383
    by Stefanie Molin
    8484

    85+
    * `Matplotlib Journey: Interactive Online Course
    86+
    <https://www.matplotlib-journey.com/>`_
    87+
    by Yan Holtz and Joseph Barbier
    88+
    8589
    =========
    8690
    Galleries
    8791
    =========

    lib/matplotlib/_cm.py

    Lines changed: 23 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -1365,6 +1365,29 @@ def _gist_yarg(x): return 1 - x
    13651365
    (0.8509803921568627, 0.8509803921568627, 0.8509803921568627 ), # d9d9d9
    13661366
    )
    13671367

    1368+
    # Colorblind accessible palettes from
    1369+
    # Matthew A. Petroff, Accessible Color Sequences for Data Visualization
    1370+
    # https://arxiv.org/abs/2107.02270
    1371+
    1372+
    _petroff6_data = (
    1373+
    (0.3411764705882353, 0.5647058823529412, 0.9882352941176471), # 5790fc
    1374+
    (0.9725490196078431, 0.611764705882353, 0.12549019607843137), # f89c20
    1375+
    (0.8941176470588236, 0.1450980392156863, 0.21176470588235294), # e42536
    1376+
    (0.5882352941176471, 0.2901960784313726, 0.5450980392156862), # 964a8b
    1377+
    (0.611764705882353, 0.611764705882353, 0.6313725490196078), # 9c9ca1
    1378+
    (0.47843137254901963, 0.12941176470588237, 0.8666666666666667), # 7a21dd
    1379+
    )
    1380+
    1381+
    _petroff8_data = (
    1382+
    (0.09411764705882353, 0.27058823529411763, 0.984313725490196), # 1845fb
    1383+
    (1.0, 0.3686274509803922, 0.00784313725490196), # ff5e02
    1384+
    (0.788235294117647, 0.12156862745098039, 0.08627450980392157), # c91f16
    1385+
    (0.7843137254901961, 0.28627450980392155, 0.6627450980392157), # c849a9
    1386+
    (0.6784313725490196, 0.6784313725490196, 0.49019607843137253), # adad7d
    1387+
    (0.5254901960784314, 0.7843137254901961, 0.8666666666666667), # 86c8dd
    1388+
    (0.3411764705882353, 0.5529411764705883, 1.0), # 578dff
    1389+
    (0.396078431372549, 0.38823529411764707, 0.39215686274509803), # 656364
    1390+
    )
    13681391

    13691392
    _petroff10_data = (
    13701393
    (0.24705882352941178, 0.5647058823529412, 0.8549019607843137), # 3f90da

    lib/matplotlib/artist.py

    Lines changed: 17 additions & 8 deletions
    Original file line numberDiff line numberDiff line change
    @@ -323,19 +323,28 @@ def get_window_extent(self, renderer=None):
    323323
    """
    324324
    Get the artist's bounding box in display space.
    325325
    326-
    The bounding box' width and height are nonnegative.
    326+
    The bounding box's width and height are non-negative.
    327327
    328328
    Subclasses should override for inclusion in the bounding box
    329329
    "tight" calculation. Default is to return an empty bounding
    330330
    box at 0, 0.
    331331
    332-
    Be careful when using this function, the results will not update
    333-
    if the artist window extent of the artist changes. The extent
    334-
    can change due to any changes in the transform stack, such as
    335-
    changing the Axes limits, the figure size, or the canvas used
    336-
    (as is done when saving a figure). This can lead to unexpected
    337-
    behavior where interactive figures will look fine on the screen,
    338-
    but will save incorrectly.
    332+
    .. warning::
    333+
    334+
    The extent can change due to any changes in the transform stack, such
    335+
    as changing the Axes limits, the figure size, the canvas used (as is
    336+
    done when saving a figure), or the DPI.
    337+
    338+
    Relying on a once-retrieved window extent can lead to unexpected
    339+
    behavior in various cases such as interactive figures being resized or
    340+
    moved to a screen with different dpi, or figures that look fine on
    341+
    screen render incorrectly when saved to file.
    342+
    343+
    To get accurate results you may need to manually call
    344+
    `matplotlib.figure.Figure.savefig` or
    345+
    `matplotlib.figure.Figure.draw_without_rendering` to have Matplotlib
    346+
    compute the rendered size.
    347+
    339348
    """
    340349
    return Bbox([[0, 0], [0, 0]])
    341350

    lib/matplotlib/axes/_axes.py

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -3748,7 +3748,7 @@ def _upcast_err(err):
    37483748
    'zorder', 'rasterized'):
    37493749
    if key in kwargs:
    37503750
    eb_cap_style[key] = kwargs[key]
    3751-
    eb_cap_style['color'] = ecolor
    3751+
    eb_cap_style["markeredgecolor"] = ecolor
    37523752

    37533753
    barcols = []
    37543754
    caplines = {'x': [], 'y': []}

    lib/matplotlib/backends/backend_pdf.py

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -766,7 +766,7 @@ def __init__(self, filename, metadata=None):
    766766
    self.writeObject(self.resourceObject, resources)
    767767

    768768
    fontNames = _api.deprecated("3.11")(property(lambda self: self._fontNames))
    769-
    dviFontNames = _api.deprecated("3.11")(property(lambda self: self._dviFontNames))
    769+
    dviFontInfo = _api.deprecated("3.11")(property(lambda self: self._dviFontInfo))
    770770
    type1Descriptors = _api.deprecated("3.11")(
    771771
    property(lambda self: self._type1Descriptors))
    772772

    lib/matplotlib/backends/backend_ps.py

    Lines changed: 0 additions & 9 deletions
    Original file line numberDiff line numberDiff line change
    @@ -1362,15 +1362,6 @@ def xpdf_distill(tmpfile, eps=False, ptype='letter', bbox=None, rotated=False):
    13621362
    pstoeps(tmpfile)
    13631363

    13641364

    1365-
    @_api.deprecated("3.9")
    1366-
    def get_bbox_header(lbrt, rotated=False):
    1367-
    """
    1368-
    Return a postscript header string for the given bbox lbrt=(l, b, r, t).
    1369-
    Optionally, return rotate command.
    1370-
    """
    1371-
    return _get_bbox_header(lbrt), (_get_rotate_command(lbrt) if rotated else "")
    1372-
    1373-
    13741365
    def _get_bbox_header(lbrt):
    13751366
    """Return a PostScript header string for bounding box *lbrt*=(l, b, r, t)."""
    13761367
    l, b, r, t = lbrt

    lib/matplotlib/colors.py

    Lines changed: 2 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -131,6 +131,8 @@ class ColorSequenceRegistry(Mapping):
    131131
    'Set1': _cm._Set1_data,
    132132
    'Set2': _cm._Set2_data,
    133133
    'Set3': _cm._Set3_data,
    134+
    'petroff6': _cm._petroff6_data,
    135+
    'petroff8': _cm._petroff8_data,
    134136
    'petroff10': _cm._petroff10_data,
    135137
    }
    136138

    lib/matplotlib/hatch.py

    Lines changed: 1 addition & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -182,6 +182,7 @@ def __init__(self, hatch, density):
    182182
    self.shape_codes = np.full(len(self.shape_vertices), Path.LINETO,
    183183
    dtype=Path.code_type)
    184184
    self.shape_codes[0] = Path.MOVETO
    185+
    self.shape_codes[-1] = Path.CLOSEPOLY
    185186
    super().__init__(hatch, density)
    186187

    187188
    _hatch_types = [

    lib/matplotlib/image.py

    Lines changed: 47 additions & 9 deletions
    C2EE
    Original file line numberDiff line numberDiff line change
    @@ -1387,8 +1387,52 @@ def set_data(self, A):
    13871387

    13881388

    13891389
    class BboxImage(_ImageBase):
    1390-
    """The Image class whose size is determined by the given bbox."""
    1390+
    """
    1391+
    The Image class whose size is determined by the given bbox.
    1392+
    1393+
    Parameters
    1394+
    ----------
    1395+
    bbox : BboxBase or Callable[RendererBase, BboxBase]
    1396+
    The bbox or a function to generate the bbox
    1397+
    1398+
    .. warning ::
    1399+
    1400+
    If using `matplotlib.artist.Artist.get_window_extent` as the
    1401+
    callable ensure that the other artist is drawn first (lower zorder)
    1402+
    or you may need to renderer the figure twice to ensure that the
    1403+
    computed bbox is accurate.
    13911404
    1405+
    cmap : str or `~matplotlib.colors.Colormap`, default: :rc:`image.cmap`
    1406+
    The Colormap instance or registered colormap name used to map scalar
    1407+
    data to colors.
    1408+
    norm : str or `~matplotlib.colors.Normalize`
    1409+
    Maps luminance to 0-1.
    1410+
    interpolation : str, default: :rc:`image.interpolation`
    1411+
    Supported values are 'none', 'auto', 'nearest', 'bilinear',
    1412+
    'bicubic', 'spline16', 'spline36', 'hanning', 'hamming', 'hermite',
    1413+
    'kaiser', 'quadric', 'catrom', 'gaussian', 'bessel', 'mitchell',
    1414+
    'sinc', 'lanczos', 'blackman'.
    1415+
    origin : {'upper', 'lower'}, default: :rc:`image.origin`
    1416+
    Place the [0, 0] index of the array in the upper left or lower left
    1417+
    corner of the Axes. The convention 'upper' is typically used for
    1418+
    matrices and images.
    1419+
    filternorm : bool, default: True
    1420+
    A parameter for the antigrain image resize filter
    1421+
    (see the antigrain documentation).
    1422+
    If filternorm is set, the filter normalizes integer values and corrects
    1423+
    the rounding errors. It doesn't do anything with the source floating
    1424+
    point values, it corrects only integers according to the rule of 1.0
    1425+
    which means that any sum of pixel weights must be equal to 1.0. So,
    1426+
    the filter function must produce a graph of the proper shape.
    1427+
    filterrad : float > 0, default: 4
    1428+
    The filter radius for filters that have a radius parameter, i.e. when
    1429+
    interpolation is one of: 'sinc', 'lanczos' or 'blackman'.
    1430+
    resample : bool, default: False
    1431+
    When True, use a full resampling method. When False, only resample when
    1432+
    the output image is larger than the input image.
    1433+
    **kwargs : `~matplotlib.artist.Artist` properties
    1434+
    1435+
    """
    13921436
    def __init__(self, bbox,
    13931437
    *,
    13941438
    cmap=None,
    @@ -1401,12 +1445,7 @@ def __init__(self, bbox,
    14011445
    resample=False,
    14021446
    **kwargs
    14031447
    ):
    1404-
    """
    1405-
    cmap is a colors.Colormap instance
    1406-
    norm is a colors.Normalize instance to map luminance to 0-1
    14071448

    1408-
    kwargs are an optional list of Artist keyword args
    1409-
    """
    14101449
    super().__init__(
    14111450
    None,
    14121451
    cmap=cmap,
    @@ -1422,12 +1461,11 @@ def __init__(self, bbox,
    14221461
    self.bbox = bbox
    14231462

    14241463
    def get_window_extent(self, renderer=None):
    1425-
    if renderer is None:
    1426-
    renderer = self.get_figure()._get_renderer()
    1427-
    14281464
    if isinstance(self.bbox, BboxBase):
    14291465
    return self.bbox
    14301466
    elif callable(self.bbox):
    1467+
    if renderer is None:
    1468+
    renderer = self.get_figure()._get_renderer()
    14311469
    return self.bbox(renderer)
    14321470
    else:
    14331471
    raise ValueError("Unknown type of bbox")

    lib/matplotlib/legend.py

    Lines changed: 1 addition & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -459,6 +459,7 @@ def __init__(
    459459
    labels = [*reversed(labels)]
    460460
    handles = [*reversed(handles)]
    461461

    462+
    handles = list(handles)
    462463
    if len(handles) < 2:
    463464
    ncols = 1
    464465
    self._ncols = ncols if ncols != 1 else ncol
    Lines changed: 5 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -0,0 +1,5 @@
    1+
    # Color cycle survey palette from Petroff (2021):
    2+
    # https://arxiv.org/abs/2107.02270
    3+
    # https://github.com/mpetroff/accessible-color-cycles
    4+
    axes.prop_cycle: cycler('color', ['5790fc', 'f89c20', 'e42536', '964a8b', '9c9ca1', '7a21dd'])
    5+
    patch.facecolor: 5790fc
    Lines changed: 5 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -0,0 +1,5 @@
    1+
    # Color cycle survey palette from Petroff (2021):
    2+
    # https://arxiv.org/abs/2107.02270
    3+
    # https://github.com/mpetroff/accessible-color-cycles
    4+
    axes.prop_cycle: cycler('color', ['1845fb', 'ff5e02', 'c91f16', 'c849a9', 'adad7d', '86c8dd', '578dff', '656364'])
    5+
    patch.facecolor: 1845fb
    Binary file not shown.
    Loading

    0 commit comments

    Comments
     (0)
    0