Skip to content

ValueError when setting zmin, zmax for rgb image #1973

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

Open
neili02 opened this issue Dec 4, 2019 · 1 comment
Open

ValueError when setting zmin, zmax for rgb image #1973

neili02 opened this issue Dec 4, 2019 · 1 comment
Labels
bug something broken P3 backlog

Comments

@neili02
Copy link

neili02 commented Dec 4, 2019

There seem to be a validation error bug for setting zmin, zmax for rgb images. It appears the validation code expects a tuple or list of size 4 ( as would be the case for rgba) and not size 3 as should be the case for rgb.

im= np.random.randint(256,size=(50,50,3),dtype=np.uint8)
fig = go.Figure(go.Image(z=im,colormodel='rgb',zmin=[10,10,10],zmax=[100,100,100]))
fig.show()

Results in the following error:

File "C:\Users\NA\Anaconda3\lib\site-packages_plotly_utils\basevalidators.py", line 283, in raise_invalid_val

valid_clr_desc=self.description(),

ValueError:
Invalid value of type 'builtins.tuple' received for the 'zmax' property of image
Received value: [100, 100, 100]

The 'zmax' property is an info array that may be specified as:

* a list or tuple of 4 elements where:

(0) The 'zmax[0]' property is a number and may be specified as:
- An int or float
(1) The 'zmax[1]' property is a number and may be specified as:
- An int or float
(2) The 'zmax[2]' property is a number and may be specified as:
- An int or float
(3) The 'zmax[3]' property is a number and may be specified as:
- An int or float

@Paul-Aime
Copy link

Bug still here, can reproduce with the following, replacing num_elements from 4 to 3:

import plotly.graph_objects as go
import numpy as np

num_elements = 4
vmin, vmax = 0, 100

fig = go.Figure(
    data=go.Image(
        z=np.random.randint(vmin, vmax, size=(32, 32, 3)),
        zmin=[vmin] * num_elements,
        zmax=[vmax] * num_elements,
        colormodel="rgb",
    )
)
fig.show()

@gvwilson gvwilson self-assigned this Jul 4, 2024
@gvwilson gvwilson removed their assignment Aug 2, 2024
@gvwilson gvwilson added P3 backlog bug something broken labels Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken P3 backlog
Projects
None yet
Development

No branches or pull requests

3 participants