diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 646b8556..121aa43c 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] + 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' }} 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] 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 diff --git a/src/tikzplotlib/_legend.py b/src/tikzplotlib/_legend.py index 29d8e635..c733e0a8 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: @@ -117,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. 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/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() 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)) 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