Skip to content

Commit

Permalink
fix(plotting): fix wrong regex in scale_units
Browse files Browse the repository at this point in the history
  • Loading branch information
kmnhan committed May 3, 2024
1 parent edaa556 commit d7826d0
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/erlab/plotting/annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,7 @@ def __init__(self, si: int = 0, *args, **kwargs):
def __call__(self, x, pos=None):
self.orderOfMagnitude += self._si_exponent

match_format = re.match(r".*{%1.(\d+)f}", self.format)
match_format = re.match(r".*%1.(\d+)f", self.format)
if match_format is None:
# Match failed, may be due to changes in matplotlib
raise RuntimeError("Failed to match format string. Please report this bug")
Expand All @@ -874,7 +874,7 @@ def __call__(self, x, pos=None):


def scale_units(
ax: matplotlib.axes.Axes,
ax: matplotlib.axes.Axes | Iterable[matplotlib.axes.Axes],
axis: Literal["x", "y", "z"],
si: int = 0,
*,
Expand Down Expand Up @@ -908,6 +908,11 @@ def scale_units(
instead.
"""
if np.iterable(ax):
for a in np.asarray(ax, dtype=object).flatten():
scale_units(a, axis, si, prefix=prefix, power=power)
return

getlabel = getattr(ax, f"get_{axis}label")
setlabel = getattr(ax, f"set_{axis}label")

Expand Down

0 comments on commit d7826d0

Please sign in to comment.