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

Use x and y parameters for Image trace in imshow (for RGB or binary_string=True) #2761

Merged
merged 6 commits into from
Nov 17, 2020

Conversation

emmanuelle
Copy link
Contributor

Closes #2758

I could only get it to work for numerical data types, I don't think the x0 and dx parameters of go.Image are meant to work with str or datetime types (could you please confirm @antoinerg?)

For example for the airtemps dataset used in the imshow tutorial, this now works
image

@nicolaskruchten
Copy link
Contributor

What does the output look like if you try this with an xarray with dates?

@nicolaskruchten
Copy link
Contributor

or should we raise in that case instead of trying to render?

@nicolaskruchten
Copy link
Contributor

@emmanuelle bump on my last comment :)

@emmanuelle
Copy link
Contributor Author

@nicolaskruchten looks like
image
(dates are converted to time intervals I guess)

I'll look into accepting only numerical types for x and y.

@nicolaskruchten
Copy link
Contributor

thanks! I think the dates are just ignored and the axis just counts pixels actually... not all that graceful :(

dx = x[1] - x[0]
else:
raise ValueError(
"Only numerical values are accepted for the `x` parameter "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is correct but I think a bit opaque for users? in the xarray case they've maybe not specified x (as it's implicit) and they don't know they're using an Image trace (all they know is they set binary_string=True

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok I can think of a better error message, but do we agree that we should also error when x is passed explicitly and does not have a numerical dtype? (otherwise it would just be ignored, which I agree is not a good thing).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the error message, is it better now?

@nicolaskruchten
Copy link
Contributor

LGTM! 💃

@emmanuelle emmanuelle merged commit 3e7967c into master Nov 17, 2020
@emmanuelle emmanuelle deleted the x-y-imshow-image branch December 1, 2020 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

x and y arguments are not taken into account when using go.Image inside px.imshow
2 participants