Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

holoview/matplotlib fails to plot a raster image with a log scale #6210

Open
WillemMarais opened this issue Apr 26, 2024 · 0 comments
Open
Labels
type: bug Something isn't correct or isn't working

Comments

@WillemMarais
Copy link

ALL software version info

holoviews 1.18.3
matplotlib 3.8.3

Description of expected behavior and the observed behavior

The following code and stack traceback shows that holoview/matplotlib fails to plot a raster image with a log scale.

Complete, minimal, self-contained example code that reproduces the issue

import numy as np
import xarray as xr
import holoviews as hv
hv.extension("matplotlib")

K, N = 100, 100

test_da = xr.DataArray(
    np.ones(shape=(K, N), dtype=np.float32)
)

test_da.hvplot.quadmesh(
    x="dim_0", 
    y="dim_1", 
    logz=True
)

Stack traceback and/or browser JavaScript console output

Traceback (most recent call last):

  File "/Users/willemm/miniconda3/envs/hsrl-infer/lib/python3.11/site-packages/holoviews/plotting/mpl/element.py", line 551, in render_artists
    handles = self.init_artists(ax, plot_data, plot_kwargs)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/Users/willemm/miniconda3/envs/hsrl-infer/lib/python3.11/site-packages/holoviews/plotting/mpl/raster.py", line 191, in init_artists
    artist = ax.pcolormesh(*plot_args, **plot_kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/Users/willemm/miniconda3/envs/hsrl-infer/lib/python3.11/site-packages/matplotlib/__init__.py", line 1465, in inner
    return func(ax, *map(sanitize_sequence, args), **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/Users/willemm/miniconda3/envs/hsrl-infer/lib/python3.11/site-packages/matplotlib/axes/_axes.py", line 6301, in pcolormesh
    collection._scale_norm(norm, vmin, vmax)

  File "/Users/willemm/miniconda3/envs/hsrl-infer/lib/python3.11/site-packages/matplotlib/cm.py", line 434, in _scale_norm
    raise ValueError(

ValueError: Passing a Normalize instance simultaneously with vmin/vmax is not supported.  Please pass vmin/vmax directly to the norm when creating it.

Suggested fix

It seems like the code between lines 193 and 195 should be placed before the call to pcolormesh. In other words, vmin and vmax should be removed prior to calling pcolormesh.

@hoxbro hoxbro added the type: bug Something isn't correct or isn't working label Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't correct or isn't working
Projects
None yet
Development

No branches or pull requests

2 participants