From d0efbe24064162a662efa0f26f1a7392ca8b7a2e Mon Sep 17 00:00:00 2001 From: pagmatt Date: Mon, 13 Feb 2023 23:04:03 +0100 Subject: [PATCH 1/9] Fix from #558 --- src/tikzplotlib/_legend.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/tikzplotlib/_legend.py b/src/tikzplotlib/_legend.py index 29d8e635..4609f80c 100644 --- a/src/tikzplotlib/_legend.py +++ b/src/tikzplotlib/_legend.py @@ -78,8 +78,13 @@ def draw_legend(data, obj): if alignment: data["current axes"].axis_options.append(f"legend cell align={{{alignment}}}") - if obj._ncol != 1: - data["current axes"].axis_options.append(f"legend columns={obj._ncol}") + try: + ncols = obj._ncols + except AttributeError: + # backwards-compatibility with matplotlib < 3.6.0 + ncols = obj._ncol + if ncols != 1: + data["current axes"].axis_options.append(f"legend columns={ncols}") # Write styles to data if legend_style: From 12c45761b73a3b34b2bd77931c227548f560bafd Mon Sep 17 00:00:00 2001 From: pagmatt Date: Fri, 29 Mar 2024 09:48:14 +0100 Subject: [PATCH 2/9] fix mpl.common_texification deprecation --- src/tikzplotlib/_axes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tikzplotlib/_axes.py b/src/tikzplotlib/_axes.py index fa84db2f..d299dd7d 100644 --- a/src/tikzplotlib/_axes.py +++ b/src/tikzplotlib/_axes.py @@ -1,7 +1,7 @@ import matplotlib as mpl import numpy as np from matplotlib.backends.backend_pgf import ( - common_texification as mpl_common_texification, + _tex_escape as mpl_common_texification, ) from . import _color From a5f85b61b9aa6b0f1019f618de1322ed14766a5c Mon Sep 17 00:00:00 2001 From: pagmatt Date: Fri, 29 Mar 2024 09:51:53 +0100 Subject: [PATCH 3/9] update CI action --- .github/workflows/ci.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 646b8556..c82966fe 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,28 +13,28 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out repo - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 - name: Run pre-commit - uses: pre-commit/action@v2.0.3 + uses: pre-commit/action@v3.0.1 build: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, windows-latest, macOS-latest] - python-version: ["3.7", "3.8", "3.9", "3.10"] + os: [ubuntu-latest, macos-latest] + python-version: ["3.8", "3.9", "3.10", "3.11"] steps: - - uses: actions/setup-python@v2 + - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 # - name: Install system dependencies # run: sudo apt-get install -y texlive-latex-base texlive-latex-extra context python3-tk - name: Test with tox run: | pip install tox tox -- --cov tikzplotlib --cov-report xml --cov-report term - - uses: codecov/codecov-action@v1 - if: ${{ matrix.python-version == '3.10' && matrix.os == 'ubuntu-latest' }} + - uses: codecov/codecov-action@v4 + if: ${{ matrix.python-version == '3.11' && matrix.os == 'ubuntu-latest' }} From c60fe441f8afd3eb56241ba8838787123a2a37cd Mon Sep 17 00:00:00 2001 From: pagmatt Date: Fri, 29 Mar 2024 10:19:15 +0100 Subject: [PATCH 4/9] test Ubuntu only --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c82966fe..121aa43c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,7 +23,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, macos-latest] + os: [ubuntu-latest] python-version: ["3.8", "3.9", "3.10", "3.11"] steps: - uses: actions/setup-python@v5 From 41c988ae1e41f616f9e6e45a51acd4eea615105d Mon Sep 17 00:00:00 2001 From: pagmatt Date: Fri, 29 Mar 2024 10:25:32 +0100 Subject: [PATCH 5/9] run tests with newer versions of mpl --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index bfe2b5b4..d6829756 100644 --- a/tox.ini +++ b/tox.ini @@ -8,7 +8,7 @@ deps = pytest pytest-cov pytest-codeblocks - matplotlib == 3.5.1 + matplotlib pytest-randomly commands = pytest {posargs} --codeblocks From efd01581ed9b0acf28b96973826b06cbbd0fb76f Mon Sep 17 00:00:00 2001 From: pagmatt Date: Fri, 29 Mar 2024 10:32:11 +0100 Subject: [PATCH 6/9] fix us.dash deprecation --- src/tikzplotlib/_path.py | 3 +-- tests/test_patches.py | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/tikzplotlib/_path.py b/src/tikzplotlib/_path.py index 11381d59..d016df60 100644 --- a/src/tikzplotlib/_path.py +++ b/src/tikzplotlib/_path.py @@ -469,8 +469,7 @@ def mpl_linestyle2pgfplots_linestyle(data, line_style, line=None): default_dashOffset, default_dashSeq = mpl.lines._get_dash_pattern(line_style) # get dash format of line under test - dashSeq = line._us_dashSeq - dashOffset = line._us_dashOffset + dashOffset, dashSeq = line._unscaled_dash_pattern lst = list() if dashSeq != default_dashSeq: diff --git a/tests/test_patches.py b/tests/test_patches.py index b8bbc7bd..28442e44 100644 --- a/tests/test_patches.py +++ b/tests/test_patches.py @@ -48,7 +48,7 @@ def plot(): ] for _ in range(N): - polygon = Polygon(np.random.rand(N, 2), True) + polygon = Polygon(np.random.rand(N, 2), closed=True) patches.append(polygon) colors = 100 * np.random.rand(len(patches)) From f4819f3b34da81bd0a773fb4b58a03e1ed5808f5 Mon Sep 17 00:00:00 2001 From: Matteo Pagin Date: Mon, 15 Jul 2024 13:02:44 +0200 Subject: [PATCH 7/9] Specify webcolors supported version 24.6.0 does not expose the constant CSS3_HEX_TO_NAMES any longer --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index f1ee514f..7d2d8530 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,7 +32,7 @@ dependencies = [ "matplotlib >= 1.4.0", "numpy", "Pillow", - "webcolors", + "webcolors <= 1.13.0", ] [project.urls] From 822e414ee427a7a800f7e3971d1f4832d5c5c580 Mon Sep 17 00:00:00 2001 From: Matteo Pagin Date: Mon, 15 Jul 2024 13:10:59 +0200 Subject: [PATCH 8/9] Reflect matplotlib switch from legend.legendHandles to legend.legend_handles --- src/tikzplotlib/_util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tikzplotlib/_util.py b/src/tikzplotlib/_util.py index 8391221c..c9a136f0 100644 --- a/src/tikzplotlib/_util.py +++ b/src/tikzplotlib/_util.py @@ -12,7 +12,7 @@ def get_legend_text(obj): if leg is None: return None - keys = [h.get_label() for h in leg.legendHandles if h is not None] + keys = [h.get_label() for h in leg.legend_handles if h is not None] values = [t.get_text() for t in leg.texts] label = obj.get_label() From 6f7bee663652fb73b8369ebb9634ecd24a870d1c Mon Sep 17 00:00:00 2001 From: Matteo Pagin Date: Mon, 15 Jul 2024 13:26:43 +0200 Subject: [PATCH 9/9] Reflect numpy dtype change from float to float16/32/64 --- src/tikzplotlib/_legend.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/tikzplotlib/_legend.py b/src/tikzplotlib/_legend.py index 4609f80c..c733e0a8 100644 --- a/src/tikzplotlib/_legend.py +++ b/src/tikzplotlib/_legend.py @@ -122,40 +122,40 @@ def _get_location_from_best(obj): # (or center) of the axes box. # 1. Key points of the legend lower_left_legend = x0_legend - lower_right_legend = np.array([x1_legend[0], x0_legend[1]], dtype=np.float_) - upper_left_legend = np.array([x0_legend[0], x1_legend[1]], dtype=np.float_) + lower_right_legend = np.array([x1_legend[0], x0_legend[1]], dtype=np.float32) + upper_left_legend = np.array([x0_legend[0], x1_legend[1]], dtype=np.float32) upper_right_legend = x1_legend center_legend = x0_legend + dimension_legend / 2.0 center_left_legend = np.array( - [x0_legend[0], x0_legend[1] + dimension_legend[1] / 2.0], dtype=np.float_ + [x0_legend[0], x0_legend[1] + dimension_legend[1] / 2.0], dtype=np.float32 ) center_right_legend = np.array( - [x1_legend[0], x0_legend[1] + dimension_legend[1] / 2.0], dtype=np.float_ + [x1_legend[0], x0_legend[1] + dimension_legend[1] / 2.0], dtype=np.float32 ) lower_center_legend = np.array( - [x0_legend[0] + dimension_legend[0] / 2.0, x0_legend[1]], dtype=np.float_ + [x0_legend[0] + dimension_legend[0] / 2.0, x0_legend[1]], dtype=np.float32 ) upper_center_legend = np.array( - [x0_legend[0] + dimension_legend[0] / 2.0, x1_legend[1]], dtype=np.float_ + [x0_legend[0] + dimension_legend[0] / 2.0, x1_legend[1]], dtype=np.float32 ) # 2. Key points of the axes lower_left_axes = x0_axes - lower_right_axes = np.array([x1_axes[0], x0_axes[1]], dtype=np.float_) - upper_left_axes = np.array([x0_axes[0], x1_axes[1]], dtype=np.float_) + lower_right_axes = np.array([x1_axes[0], x0_axes[1]], dtype=np.float32) + upper_left_axes = np.array([x0_axes[0], x1_axes[1]], dtype=np.float32) upper_right_axes = x1_axes center_axes = x0_axes + dimension_axes / 2.0 center_left_axes = np.array( - [x0_axes[0], x0_axes[1] + dimension_axes[1] / 2.0], dtype=np.float_ + [x0_axes[0], x0_axes[1] + dimension_axes[1] / 2.0], dtype=np.float32 ) center_right_axes = np.array( - [x1_axes[0], x0_axes[1] + dimension_axes[1] / 2.0], dtype=np.float_ + [x1_axes[0], x0_axes[1] + dimension_axes[1] / 2.0], dtype=np.float32 ) lower_center_axes = np.array( - [x0_axes[0] + dimension_axes[0] / 2.0, x0_axes[1]], dtype=np.float_ + [x0_axes[0] + dimension_axes[0] / 2.0, x0_axes[1]], dtype=np.float32 ) upper_center_axes = np.array( - [x0_axes[0] + dimension_axes[0] / 2.0, x1_axes[1]], dtype=np.float_ + [x0_axes[0] + dimension_axes[0] / 2.0, x1_axes[1]], dtype=np.float32 ) # 3. Compute the distances between comparable points.