From 4c2d2b9ba3d18edb009d1077c45f469e78133236 Mon Sep 17 00:00:00 2001 From: Daniel Kohler <11864045+ddkohler@users.noreply.github.com> Date: Wed, 29 May 2024 14:28:54 -0500 Subject: [PATCH 1/7] rework artists.stitch_to_animation use pathlib use pillow new kwargs --- WrightTools/artists/_helpers.py | 57 +++++++++++++++++++++++++-------- setup.py | 10 +++--- 2 files changed, 49 insertions(+), 18 deletions(-) diff --git a/WrightTools/artists/_helpers.py b/WrightTools/artists/_helpers.py index 9b2e6a5c..c28a4185 100644 --- a/WrightTools/artists/_helpers.py +++ b/WrightTools/artists/_helpers.py @@ -3,7 +3,7 @@ # --- import -------------------------------------------------------------------------------------- -import os +import pathlib import numpy as np @@ -877,7 +877,7 @@ def savefig(path, fig=None, close=True, **kwargs): if fig is None: fig = plt.gcf() - path = os.path.abspath(path) + path = pathlib.Path(path).resolve() kwargs["dpi"] = kwargs.get("dpi", 300) kwargs["transparent"] = kwargs.get("transparent", False) @@ -1085,7 +1085,9 @@ def subplots_adjust(fig=None, inches=1): fig.subplots_adjust(top=top, right=right, bottom=bottom, left=left) -def stitch_to_animation(paths, outpath=None, *, duration=0.5, palettesize=256, verbose=True): +def stitch_to_animation( + paths, outpath=None, *, duration=0.5, ignore_alpha=True, reduce=None, verbose=True, **kwargs +): """Stitch a series of images into an animation. Currently supports animated gifs, other formats coming as needed. @@ -1099,23 +1101,52 @@ def stitch_to_animation(paths, outpath=None, *, duration=0.5, palettesize=256, v of first path in `images`. Default is None. duration : number or list of numbers (optional) Duration of (each) frame in seconds. Default is 0.5. - palettesize : int (optional) - The number of colors in the resulting animation. Input is rounded to - the nearest power of 2. Default is 256. + ignore_transparency : bool (optional) + When True, transparency is excluded from the gif and color palette may be higher res. ignoring alpha takes longer and produces larger gifs + reduce : int (optional) + Reduces the resolution along both image dimensions by a factor of `reduce`. verbose : bool (optional) Toggle talkback. Default is True. + + Returns: + -------- + outpath : pathlib.Path + path to generated gif """ + import contextlib + from PIL import Image + # parse filename if outpath is None: - outpath = os.path.splitext(paths[0])[0] + ".gif" + outpath = pathlib.Path(paths[0]).with_suffix(".gif") # write t = wt_kit.Timer(verbose=False) - with t, iio.imopen(outpath, "w") as gif: - for p in paths: - frame = iio.imread(p) - gif.write( - frame, plugin="pillow", duration=duration * 1e3, loop=0, palettesize=palettesize - ) + + def process_imgs(imgs): + count = 0 + for img in imgs: + if verbose: + print(f"processing {count+1} / {len(paths)}...") + if ignore_alpha: + img = img.convert("RGB") + if reduce is not None: + img = img.reduce(reduce) + count += 1 + yield img + + with t, contextlib.ExitStack() as stack: + imgs = process_imgs(stack.enter_context(Image.open(p)) for p in paths) + img = next(imgs) + img.save( + fp=outpath, + format="GIF", + append_images=imgs, + save_all=True, + duration=duration * 1e3, + loop=0, + **kwargs, + ) + if verbose: interval = np.round(t.interval, 2) print("gif generated in {0} seconds - saved at {1}".format(interval, outpath)) diff --git a/setup.py b/setup.py index d4fe3588..16ae3faa 100755 --- a/setup.py +++ b/setup.py @@ -1,14 +1,14 @@ #! /usr/bin/env python3 -import os +import pathlib from setuptools import setup, find_packages -here = os.path.abspath(os.path.dirname(__file__)) +here = pathlib.Path(__file__).resolve().parent def read(fname): - with open(os.path.join(here, fname)) as f: + with open(here / fname) as f: return f.read() @@ -25,7 +25,7 @@ def read(fname): ] } -with open(os.path.join(here, "WrightTools", "VERSION")) as version_file: +with open(here / "WrightTools" / "VERSION") as version_file: version = version_file.read().strip() docs_require = ["sphinx", "sphinx-gallery==0.8.2", "sphinx-rtd-theme"] @@ -37,7 +37,7 @@ def read(fname): python_requires=">=3.7", install_requires=[ "h5py", - "imageio>=2.28.0", + "pillow", "matplotlib>=3.4.0", "numexpr", "numpy>=1.15.0", From 38c6d265a61a107cace01376ba9fa1e4e1bf6aec Mon Sep 17 00:00:00 2001 From: Daniel Kohler <11864045+ddkohler@users.noreply.github.com> Date: Thu, 30 May 2024 11:25:37 -0500 Subject: [PATCH 2/7] docs --- CHANGELOG.md | 2 ++ WrightTools/artists/_helpers.py | 20 +++++++++----------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bd1e54d5..aedc65ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/). - new artist helper function: `norm_from_channel` - new artist helper function: `ticks_from_norm` - new artist iterator `ChopHandler` +- `artists.stitch_to_animation`: new kwargs for more gif customization ### Fixed - fixed Quick2D/Quick1D issues where collapsing unused dims did not work @@ -17,6 +18,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/). - constants in chopped data will inherit the units of the original data ## Changed +- use `pillow` directly and remove `ImageIO` dependency - refactor of artists.quick1D and artists.quick2D - quick2D and quick1D will not force `autosave=True` if the number of figures is large. Instead, interactive plotting will be truncated if the number of figures is large. - artists now gets turbo colormap straight from matplotlib diff --git a/WrightTools/artists/_helpers.py b/WrightTools/artists/_helpers.py index c28a4185..bed113a7 100644 --- a/WrightTools/artists/_helpers.py +++ b/WrightTools/artists/_helpers.py @@ -15,6 +15,7 @@ from matplotlib.colors import Normalize, CenteredNorm, TwoSlopeNorm from mpl_toolkits.axes_grid1 import make_axes_locatable +from typing import List import imageio.v3 as iio import warnings @@ -1086,23 +1087,20 @@ def subplots_adjust(fig=None, inches=1): def stitch_to_animation( - paths, outpath=None, *, duration=0.5, ignore_alpha=True, reduce=None, verbose=True, **kwargs + paths, outpath=None, duration=0.5, ignore_alpha:bool=True, reduce:int=None, verbose=True, **kwargs ): - """Stitch a series of images into an animation. - - Currently supports animated gifs, other formats coming as needed. + """Stitch a series of images into a gif. Parameters ---------- paths : list of strings - Filepaths to the images to stitch together, in order of apperence. + Filepaths to the images to stitch together, in order of appearance. outpath : string (optional) - Path of output, including extension. If None, bases output path on path - of first path in `images`. Default is None. + Path of output, including extension. If None, bases output path on `paths[0]`. Default is None. duration : number or list of numbers (optional) Duration of (each) frame in seconds. Default is 0.5. - ignore_transparency : bool (optional) - When True, transparency is excluded from the gif and color palette may be higher res. ignoring alpha takes longer and produces larger gifs + ignore_alpha : bool (optional) + When True, transparency is excluded from the gif and color palette may be higher res. reduce : int (optional) Reduces the resolution along both image dimensions by a factor of `reduce`. verbose : bool (optional) @@ -1110,7 +1108,7 @@ def stitch_to_animation( Returns: -------- - outpath : pathlib.Path + outpath : path-like path to generated gif """ import contextlib @@ -1122,7 +1120,7 @@ def stitch_to_animation( # write t = wt_kit.Timer(verbose=False) - def process_imgs(imgs): + def process_imgs(imgs:List[Image.Image]): count = 0 for img in imgs: if verbose: From b64a93aab2144b75c8ff4e0b48d58a1836a2fbdf Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 30 May 2024 16:26:25 +0000 Subject: [PATCH 3/7] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- WrightTools/artists/_helpers.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/WrightTools/artists/_helpers.py b/WrightTools/artists/_helpers.py index bed113a7..7f72d919 100644 --- a/WrightTools/artists/_helpers.py +++ b/WrightTools/artists/_helpers.py @@ -1087,7 +1087,13 @@ def subplots_adjust(fig=None, inches=1): def stitch_to_animation( - paths, outpath=None, duration=0.5, ignore_alpha:bool=True, reduce:int=None, verbose=True, **kwargs + paths, + outpath=None, + duration=0.5, + ignore_alpha: bool = True, + reduce: int = None, + verbose=True, + **kwargs, ): """Stitch a series of images into a gif. @@ -1120,7 +1126,7 @@ def stitch_to_animation( # write t = wt_kit.Timer(verbose=False) - def process_imgs(imgs:List[Image.Image]): + def process_imgs(imgs: List[Image.Image]): count = 0 for img in imgs: if verbose: From 9416ce65d67e0864d2798cbda901d330d2c29daa Mon Sep 17 00:00:00 2001 From: Daniel Kohler <11864045+ddkohler@users.noreply.github.com> Date: Sat, 14 Mar 2026 14:36:54 -0500 Subject: [PATCH 4/7] Update pyproject.toml --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 72a81833..57a3c5bc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,7 +11,7 @@ requires-python = ">=3.7" dynamic = ["version"] dependencies = [ "h5py", - "imageio>=2.28.0", + "pillow", "matplotlib>=3.4.0", "numexpr", "numpy>=1.15.0", From 2b0f54ee794333de0c8026acbea7d6ade6f5e1f0 Mon Sep 17 00:00:00 2001 From: Daniel Kohler <11864045+ddkohler@users.noreply.github.com> Date: Sat, 14 Mar 2026 14:36:56 -0500 Subject: [PATCH 5/7] Create norms.py --- examples/norms.py | 138 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100644 examples/norms.py diff --git a/examples/norms.py b/examples/norms.py new file mode 100644 index 00000000..9026b177 --- /dev/null +++ b/examples/norms.py @@ -0,0 +1,138 @@ +""" +use the right combination of colorbar and matplotlib norms +to communicate your data! +""" + +import WrightTools as wt +from WrightTools import datasets + +import matplotlib.colors as mpl_colors +from matplotlib import colormaps as colormaps + +import numpy as np + + +# --- colormaps ----------------------------------------------------------------------------------- +unsigned_cmap = [ + wt.artists.colormaps["default"].copy(), + colormaps["cubehelix_r"], + colormaps["magma_r"], + colormaps["viridis_r"], +][0] +unsigned_cmap.set_under([0.9, 0.9, 0.9, 1]) + +cyclic_cmap = "twilight" + +signed_cmap = ["twilight_shifted", "RdBu", "coolwarm", "seismic"][1] + + +# --- data ---------------------------------------------------------------------------------------- +p = datasets.wt5.v1p0p0_perovskite_TA +signed = wt.open(p).at(d2=[-15, "fs"]).split("w1", [1.6])[1] +signed.bring_to_front("signal_diff") + +unsigned = wt.data.from_PyCMDS(r"https://osf.io/75vny/download") +unsigned.bring_to_front("signal_diff") +unsigned.convert("eV") +unsigned.signal_diff.normalize() + + +# --- plot ---------------------------------------------------------------------------------------- +label_kwargs = dict(fontsize=14, corner="LR", background_alpha=0.6) +fig, gs = wt.artists.create_figure(width=8, cols=[1, 1], nrows=4, wspace=1.3) + + +# --- unsigned data ------------------------------------------------------------------------------- +# --- --- linear ---------------------------------------------------------------------------------- +ax00 = fig.add_subplot(gs[0, 0], label="00 - unsigned linear") +wt.artists.corner_text("linear", **label_kwargs) +art = ax00.pcolormesh(unsigned, cmap=unsigned_cmap, autolabel="y") +fig.colorbar(art, ax=ax00, extend="min") + +ax00.set_title("unsigned data") + +# --- --- sqrt ------------------------------------------------------------------------------------ +ax10 = fig.add_subplot(gs[1, 0], label="10 - unsigned sqrt") +wt.artists.corner_text("sqrt", **label_kwargs) +# norm = mpl_colors.PowerNorm(gamma=0.5, vmin=0) +""" +NOTE: a bug with PowerNorm makes the colorbar extend arrow incorrect color +as recently as mpl 3.8.3. +a fix has been applied upstream; we just have to wait for it +https://github.com/matplotlib/matplotlib/pull/27589 +in the meantime, we can define a custom norm to get past the issue +""" +_forward = lambda x: np.sign(x) * np.sqrt(np.abs(x)) +_inverse = lambda x: np.sign(x) * x**2 +norm = mpl_colors.FuncNorm((_forward, _inverse), vmin=0, clip=False) +art = ax10.pcolormesh(unsigned, norm=norm, cmap=unsigned_cmap, autolabel="y") +fig.colorbar(art, ax=ax10, extend="min") + +# --- --- log10 ----------------------------------------------------------------------------------- +ax20 = fig.add_subplot(gs[2, 0], label="20 - unsigned log") +wt.artists.corner_text("log10", **label_kwargs) +norm = mpl_colors.LogNorm(vmin=5e-4, clip=False) +art = ax20.pcolormesh(unsigned, norm=norm, cmap=unsigned_cmap, autolabel="y") +cblog = fig.colorbar(art, ax=ax20, extend="min") + +# --- --- log10, decadic cycles ------------------------------------------------------------------- +# currently a bit hackish, but works. We could make tools for this +ax30 = fig.add_subplot(gs[3, 0], label="30 - unsigned log cyclic") +wt.artists.corner_text("log10, cyclic", **label_kwargs) +mantissa = lambda x: np.mod(np.log10(x), -1) +unsigned.create_channel("mantissa", values=10 ** mantissa(unsigned.signal_diff[:])) +norm = mpl_colors.LogNorm() +art = ax30.pcolormesh(unsigned, channel="mantissa", norm=norm, cmap=cyclic_cmap, autolabel="both") +cb = fig.colorbar(art, ax=ax30) +cb.ax.yaxis.set_minor_formatter("{x:0.1f}") +cb.ax.set_yticks([0.1, 0.2, 0.5], minor=True) # , labels=["0.2", "0.5"], minor=True) + +# --- plot signed data --------------------------------------------------------------------------- +# --- --- linear norm ---------------------------------------------------------------------------- +ax01 = fig.add_subplot(gs[0, 1], label="01 - signed linear") +ax01.set_title("signed data") +wt.artists.corner_text("linear", **label_kwargs) +art = ax01.pcolormesh(signed, cmap=signed_cmap, autolabel="y") +fig.colorbar(art, ax=ax01) + +# --- --- bilinear norm -------------------------------------------------------------------------- +ax11 = fig.add_subplot(gs[1, 1], label="11 - signed bilinear") +wt.artists.corner_text("bilinear", **label_kwargs) +norm = mpl_colors.TwoSlopeNorm(vcenter=signed.signal_diff.null) +art = ax11.pcolormesh(signed, norm=norm, cmap=signed_cmap, autolabel="y") +cb = fig.colorbar(art, ax=ax11) +cb.ax.set_yscale("linear") + +# --- --- asinh norm ------------------------------------------------------------------------------ +ax21 = fig.add_subplot(gs[2, 1], label="21 - signed asinh") +wt.artists.corner_text("asinh", **label_kwargs) +norm = mpl_colors.AsinhNorm( + linear_width=1e-3, vmin=-signed.signal_diff.mag(), vmax=signed.signal_diff.mag() +) +art = ax21.pcolormesh(signed, norm=norm, cmap=signed_cmap, autolabel="y") +fig.colorbar(art, ax=ax21) + +# --- --- symlog norm ----------------------------------------------------------------------------- +ax31 = fig.add_subplot(gs[3, 1], label="31 - signed symlog") +wt.artists.corner_text("symLog", **label_kwargs) +norm = mpl_colors.SymLogNorm( + linthresh=1e-3, vmin=-signed.signal_diff.mag(), vmax=signed.signal_diff.mag() +) +art = ax31.pcolormesh(signed, norm=norm, cmap=signed_cmap, autolabel="both") +fig.colorbar(art, ax=ax31) + + +# --- final decorations --------------------------------------------------------------------------- + +for ax in fig.axes: + label = ax.get_label() + if label == "": + continue + ax.grid(c="k", lw=1, ls="-.", alpha=0.5) + if label[0] != "3": # not bottom row + ax.set_xticks(ax.get_xticks(), ax.get_xticklabels(), visible=False) + ax.set_xticks(ax.get_yticks()) + if label[1] == "0": # unsigned + ax.set_xlim(unsigned.w2.min(), unsigned.w2.max()) + else: + ax.set_xlim(signed.w1.min(), signed.w1.max()) From dcca3dc7eb932e94700a77604dfdde38a6f2c36d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 14 Mar 2026 19:37:08 +0000 Subject: [PATCH 6/7] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- examples/norms.py | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/norms.py b/examples/norms.py index 9026b177..0e394045 100644 --- a/examples/norms.py +++ b/examples/norms.py @@ -11,7 +11,6 @@ import numpy as np - # --- colormaps ----------------------------------------------------------------------------------- unsigned_cmap = [ wt.artists.colormaps["default"].copy(), From b41840cfd8591ffe5c00bca9935cbfde8d1d9732 Mon Sep 17 00:00:00 2001 From: Daniel Kohler <11864045+ddkohler@users.noreply.github.com> Date: Sat, 14 Mar 2026 23:05:29 -0500 Subject: [PATCH 7/7] Delete norms.py --- examples/norms.py | 137 ---------------------------------------------- 1 file changed, 137 deletions(-) delete mode 100644 examples/norms.py diff --git a/examples/norms.py b/examples/norms.py deleted file mode 100644 index 0e394045..00000000 --- a/examples/norms.py +++ /dev/null @@ -1,137 +0,0 @@ -""" -use the right combination of colorbar and matplotlib norms -to communicate your data! -""" - -import WrightTools as wt -from WrightTools import datasets - -import matplotlib.colors as mpl_colors -from matplotlib import colormaps as colormaps - -import numpy as np - -# --- colormaps ----------------------------------------------------------------------------------- -unsigned_cmap = [ - wt.artists.colormaps["default"].copy(), - colormaps["cubehelix_r"], - colormaps["magma_r"], - colormaps["viridis_r"], -][0] -unsigned_cmap.set_under([0.9, 0.9, 0.9, 1]) - -cyclic_cmap = "twilight" - -signed_cmap = ["twilight_shifted", "RdBu", "coolwarm", "seismic"][1] - - -# --- data ---------------------------------------------------------------------------------------- -p = datasets.wt5.v1p0p0_perovskite_TA -signed = wt.open(p).at(d2=[-15, "fs"]).split("w1", [1.6])[1] -signed.bring_to_front("signal_diff") - -unsigned = wt.data.from_PyCMDS(r"https://osf.io/75vny/download") -unsigned.bring_to_front("signal_diff") -unsigned.convert("eV") -unsigned.signal_diff.normalize() - - -# --- plot ---------------------------------------------------------------------------------------- -label_kwargs = dict(fontsize=14, corner="LR", background_alpha=0.6) -fig, gs = wt.artists.create_figure(width=8, cols=[1, 1], nrows=4, wspace=1.3) - - -# --- unsigned data ------------------------------------------------------------------------------- -# --- --- linear ---------------------------------------------------------------------------------- -ax00 = fig.add_subplot(gs[0, 0], label="00 - unsigned linear") -wt.artists.corner_text("linear", **label_kwargs) -art = ax00.pcolormesh(unsigned, cmap=unsigned_cmap, autolabel="y") -fig.colorbar(art, ax=ax00, extend="min") - -ax00.set_title("unsigned data") - -# --- --- sqrt ------------------------------------------------------------------------------------ -ax10 = fig.add_subplot(gs[1, 0], label="10 - unsigned sqrt") -wt.artists.corner_text("sqrt", **label_kwargs) -# norm = mpl_colors.PowerNorm(gamma=0.5, vmin=0) -""" -NOTE: a bug with PowerNorm makes the colorbar extend arrow incorrect color -as recently as mpl 3.8.3. -a fix has been applied upstream; we just have to wait for it -https://github.com/matplotlib/matplotlib/pull/27589 -in the meantime, we can define a custom norm to get past the issue -""" -_forward = lambda x: np.sign(x) * np.sqrt(np.abs(x)) -_inverse = lambda x: np.sign(x) * x**2 -norm = mpl_colors.FuncNorm((_forward, _inverse), vmin=0, clip=False) -art = ax10.pcolormesh(unsigned, norm=norm, cmap=unsigned_cmap, autolabel="y") -fig.colorbar(art, ax=ax10, extend="min") - -# --- --- log10 ----------------------------------------------------------------------------------- -ax20 = fig.add_subplot(gs[2, 0], label="20 - unsigned log") -wt.artists.corner_text("log10", **label_kwargs) -norm = mpl_colors.LogNorm(vmin=5e-4, clip=False) -art = ax20.pcolormesh(unsigned, norm=norm, cmap=unsigned_cmap, autolabel="y") -cblog = fig.colorbar(art, ax=ax20, extend="min") - -# --- --- log10, decadic cycles ------------------------------------------------------------------- -# currently a bit hackish, but works. We could make tools for this -ax30 = fig.add_subplot(gs[3, 0], label="30 - unsigned log cyclic") -wt.artists.corner_text("log10, cyclic", **label_kwargs) -mantissa = lambda x: np.mod(np.log10(x), -1) -unsigned.create_channel("mantissa", values=10 ** mantissa(unsigned.signal_diff[:])) -norm = mpl_colors.LogNorm() -art = ax30.pcolormesh(unsigned, channel="mantissa", norm=norm, cmap=cyclic_cmap, autolabel="both") -cb = fig.colorbar(art, ax=ax30) -cb.ax.yaxis.set_minor_formatter("{x:0.1f}") -cb.ax.set_yticks([0.1, 0.2, 0.5], minor=True) # , labels=["0.2", "0.5"], minor=True) - -# --- plot signed data --------------------------------------------------------------------------- -# --- --- linear norm ---------------------------------------------------------------------------- -ax01 = fig.add_subplot(gs[0, 1], label="01 - signed linear") -ax01.set_title("signed data") -wt.artists.corner_text("linear", **label_kwargs) -art = ax01.pcolormesh(signed, cmap=signed_cmap, autolabel="y") -fig.colorbar(art, ax=ax01) - -# --- --- bilinear norm -------------------------------------------------------------------------- -ax11 = fig.add_subplot(gs[1, 1], label="11 - signed bilinear") -wt.artists.corner_text("bilinear", **label_kwargs) -norm = mpl_colors.TwoSlopeNorm(vcenter=signed.signal_diff.null) -art = ax11.pcolormesh(signed, norm=norm, cmap=signed_cmap, autolabel="y") -cb = fig.colorbar(art, ax=ax11) -cb.ax.set_yscale("linear") - -# --- --- asinh norm ------------------------------------------------------------------------------ -ax21 = fig.add_subplot(gs[2, 1], label="21 - signed asinh") -wt.artists.corner_text("asinh", **label_kwargs) -norm = mpl_colors.AsinhNorm( - linear_width=1e-3, vmin=-signed.signal_diff.mag(), vmax=signed.signal_diff.mag() -) -art = ax21.pcolormesh(signed, norm=norm, cmap=signed_cmap, autolabel="y") -fig.colorbar(art, ax=ax21) - -# --- --- symlog norm ----------------------------------------------------------------------------- -ax31 = fig.add_subplot(gs[3, 1], label="31 - signed symlog") -wt.artists.corner_text("symLog", **label_kwargs) -norm = mpl_colors.SymLogNorm( - linthresh=1e-3, vmin=-signed.signal_diff.mag(), vmax=signed.signal_diff.mag() -) -art = ax31.pcolormesh(signed, norm=norm, cmap=signed_cmap, autolabel="both") -fig.colorbar(art, ax=ax31) - - -# --- final decorations --------------------------------------------------------------------------- - -for ax in fig.axes: - label = ax.get_label() - if label == "": - continue - ax.grid(c="k", lw=1, ls="-.", alpha=0.5) - if label[0] != "3": # not bottom row - ax.set_xticks(ax.get_xticks(), ax.get_xticklabels(), visible=False) - ax.set_xticks(ax.get_yticks()) - if label[1] == "0": # unsigned - ax.set_xlim(unsigned.w2.min(), unsigned.w2.max()) - else: - ax.set_xlim(signed.w1.min(), signed.w1.max())