Skip to content

Commit 8f3c5b9

Browse files
committed
Update adjustText and other fixes
1 parent 8f8f525 commit 8f3c5b9

File tree

7 files changed

+36
-20
lines changed

7 files changed

+36
-20
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
strategy:
1414
matrix:
1515
python-version: ["3.10", "3.11", "3.12", "3.13"]
16-
mpl-version: ["3.7", "3.8", "3.9", "3.10", "latest"]
16+
mpl-version: ["3.9", "3.10", "latest"]
1717
exclude:
1818
# Latest MPL requires Python 3.11
1919
- mpl-version: "latest"
@@ -67,7 +67,7 @@ jobs:
6767
strategy:
6868
matrix:
6969
python-version: ["3.11"]
70-
mpl-version: ["3.7", "latest"]
70+
mpl-version: ["3.9", "latest"]
7171
steps:
7272
- name: Checkout
7373
uses: actions/checkout@v3

.pre-commit-config.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,13 @@ repos:
4545
hooks:
4646
- id: pyupgrade
4747
args: [--py310-plus]
48+
49+
- repo: https://github.com/codespell-project/codespell
50+
rev: v2.4.1
51+
hooks:
52+
- id: codespell
53+
54+
- repo: https://github.com/shssoichiro/oxipng
55+
rev: v9.1.5
56+
hooks:
57+
- id: oxipng

changelog.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,17 @@ Changed
3131
- BREAKING: The *only_name_when_one* argument to :class:`.FactorFormatter` was replaced with
3232
*name_on_all_numbers*, so that, e.g., the degree sign is always shown.
3333
- BREAKING: All functions in :mod:`mplsignal.scipyplot` now use a constrained layout. This
34-
will in general make the plot clearer, although at the expense of margin.
34+
will in general make the plot clearer, although at the expense of less margin.
3535
- Minimum Python version is increased to 3.10.
36+
- Minimum adjustText version is set to 1.3.
37+
- Minimum Matplotlib version is increased to 3.9.
3638

3739
Fixed
3840
^^^^^
3941

4042
- ``freq_unit`` was not propagated properly in all ``freq_plots.zfreq*`` functions and
4143
``style``-combinations.
44+
- The ``adjust`` argument to the ``*plane`` functions is removed as it is not supported by newer versions of adjustText.
4245

4346
[0.2.0] - 2023-03-05
4447
--------------------

lib/mplsignal/plane_plots.py

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ def zplane(
2222
zeros=None,
2323
poles=None,
2424
ax=None,
25-
adjust=1,
2625
spinelinewidth: float = 0.2,
2726
spinecolor='black',
2827
zeromarker='o',
@@ -52,9 +51,6 @@ def zplane(
5251
ax : :class:`~matplotlib.axes.Axes`, optional
5352
Axes to plot in.
5453
55-
adjust : int, default: 1
56-
Number of times to execute text adjustment. Set to 0 to disable.
57-
5854
spinelinewidth : float, default: 0.2
5955
Line width of spines.
6056
@@ -162,7 +158,7 @@ def zplane(
162158
linewidth=spinelinewidth,
163159
)
164160
)
165-
texts = _plot_plane(
161+
xvals, yvals, texts = _plot_plane(
166162
zeros,
167163
poles,
168164
ax=ax,
@@ -173,12 +169,9 @@ def zplane(
173169
multiplicity_props=multiplicity_props,
174170
**kwargs,
175171
)
176-
if texts:
177-
for _ in range(adjust):
178-
# Fix for adjustText = 0.8
179-
ax.figure.draw_without_rendering()
180-
adjustText.adjust_text(texts, ax=ax)
181172
ax.axis('equal')
173+
if texts:
174+
adjustText.adjust_text(texts, x=xvals, y=yvals, ax=ax)
182175
return ax
183176

184177

@@ -292,7 +285,9 @@ def _plot_plane(
292285
-------
293286
List of texts.
294287
"""
295-
ret = []
288+
text_items = []
289+
xvals = []
290+
yvals = []
296291
if multiplicity_props is None:
297292
multiplicity_props = {}
298293
if zeros is not None:
@@ -304,7 +299,11 @@ def _plot_plane(
304299
**zero_props,
305300
**kwargs,
306301
)
307-
ret += [ax.text(x, y, text, **multiplicity_props) for x, y, text in texts]
302+
xvals.extend(x_pos)
303+
yvals.extend(y_pos)
304+
text_items.extend(
305+
ax.text(x, y, text, **multiplicity_props) for x, y, text in texts
306+
)
308307

309308
if poles is not None:
310309
poles_d = _get_multiplicities(poles)
@@ -315,11 +314,15 @@ def _plot_plane(
315314
**pole_props,
316315
**kwargs,
317316
)
318-
ret += [ax.text(x, y, text, **multiplicity_props) for x, y, text in texts]
317+
xvals.extend(x_pos)
318+
yvals.extend(y_pos)
319+
text_items.extend(
320+
ax.text(x, y, text, **multiplicity_props) for x, y, text in texts
321+
)
319322

320323
ax.set_xlabel(reallabel)
321324
ax.set_ylabel(imaglabel)
322-
return ret
325+
return xvals, yvals, text_items
323326

324327

325328
def _is_close(x, y):

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ name = "mplsignal"
33
description = "Matplotlib extension for signal processing-related plots"
44
authors = [{ name = "Oscar Gustafsson", email = "oscar.gustafsson@gmail.com" }]
55
requires-python = ">=3.10"
6-
license = { file = "LICENSE" }
6+
license = "BSD-3-clause"
7+
license-files = ["LICENSE"]
78
readme = "README.md"
89
dynamic = ["version"]
9-
dependencies = ["matplotlib>=3.9", "adjustText"]
10+
dependencies = ["matplotlib>=3.9", "adjustText>=1.3"]
1011
classifiers = [
1112
"Development Status :: 3 - Alpha",
1213
"Framework :: Matplotlib",
1314
"Intended Audience :: Developers",
1415
"Intended Audience :: Science/Research",
15-
"License :: OSI Approved :: BSD License",
1616
"Programming Language :: Python",
1717
"Programming Language :: Python :: 3",
1818
"Programming Language :: Python :: 3.10",
-5.14 KB
Loading
-5.86 KB
Loading

0 commit comments

Comments
 (0)