From d8c9a2d296ee8ee1b1c928a548b490103ca4d961 Mon Sep 17 00:00:00 2001 From: Xylar Asay-Davis Date: Wed, 12 Mar 2025 05:08:54 -0500 Subject: [PATCH] Fix planar plots with log norm We can't pass `vmin` and `vmax` along with `norm` that also tried to define the min and max: ``` ValueError: Passing a Normalize instance simultaneously with vmin/vmax is not supported. Please pass vmin/vmax directly to the norm when creating it. ``` This merge also drops an attempt to keep `vmin` positive for log norm, instead requiring the calling code to set reasonable bounds for log plots. --- polaris/viz/planar.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/polaris/viz/planar.py b/polaris/viz/planar.py index 29d3861128..270546e7f1 100644 --- a/polaris/viz/planar.py +++ b/polaris/viz/planar.py @@ -41,10 +41,12 @@ def plot_horiz_field(ds_mesh, field, out_file_name=None, # noqa: C901 The title of the plot vmin : float, optional - The minimum values for the colorbar + The minimum values for the colorbar; if provided, must be positive if + ``cmap_scale == 'log'`` vmax : float, optional - The maximum values for the colorbar + The maximum values for the colorbar; if provided, must be positive if + ``cmap_scale == 'log'`` show_patch_edges : boolean, optional If true, patches will be plotted with visible edges @@ -165,8 +167,10 @@ def plot_horiz_field(ds_mesh, field, out_file_name=None, # noqa: C901 if cmap_scale == 'log': pcolor_kwargs['norm'] = LogNorm( - vmin=max(1e-10, vmin), vmax=vmax, clip=False + vmin=vmin, vmax=vmax, clip=False ) + pcolor_kwargs.pop('vmin', None) + pcolor_kwargs.pop('vmax', None) if figsize is None: width = ds_mesh.xCell.max() - ds_mesh.xCell.min()