X Tutup
The Wayback Machine - https://web.archive.org/web/20220319232534/https://github.com/plotly/plotly.py/pull/2761
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

@emmanuelle emmanuelle commented Sep 10, 2020

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
Member

@nicolaskruchten nicolaskruchten commented Nov 12, 2020

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

@nicolaskruchten
Copy link
Member

@nicolaskruchten nicolaskruchten commented Nov 12, 2020

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

@nicolaskruchten
Copy link
Member

@nicolaskruchten nicolaskruchten commented Nov 16, 2020

@emmanuelle bump on my last comment :)

@emmanuelle
Copy link
Contributor Author

@emmanuelle emmanuelle commented Nov 17, 2020

@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
Member

@nicolaskruchten nicolaskruchten commented Nov 17, 2020

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
Member

@nicolaskruchten nicolaskruchten Nov 17, 2020

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

@emmanuelle emmanuelle Nov 17, 2020

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

@emmanuelle emmanuelle Nov 17, 2020

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
Member

@nicolaskruchten nicolaskruchten commented Nov 17, 2020

LGTM! 💃

@emmanuelle emmanuelle merged commit 3e7967c into master Nov 17, 2020
16 checks passed
@emmanuelle emmanuelle deleted the x-y-imshow-image branch Dec 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

2 participants
X Tutup