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

Remove the scaleanchor constrain on axes having an image trace #6709

Closed
josephernest opened this issue Aug 17, 2023 · 5 comments · Fixed by #6712
Closed

Remove the scaleanchor constrain on axes having an image trace #6709

josephernest opened this issue Aug 17, 2023 · 5 comments · Fixed by #6712
Labels
feature something new

Comments

@josephernest
Copy link

In Keep square pixels + ability to have any rectangular shape zoom with Plotly.js, with a plot with 2 layers's answer by @lvlte, we see that it is sometimes useful to be able to remove the scaleanchor constrain applied by default on axes having an image trace.

But this doesn't work: setting scaleanchor: false on either or both axes has no effect.

The easiest solution is to patch, in https://github.com/plotly/plotly.js/blob/v2.25.2/src/plots/cartesian/constraints.js#L34,

hasImage: axHasImage[axName]

by

hasImage: false

but this is not a solution in the long-term.

Do you think it could be useful to add a setting to avoid this manual patching?

@josephernest josephernest changed the title Remove the scaleanchor constrain applied by default on axes having an image trace Remove the scaleanchor constrain on axes having an image trace Aug 17, 2023
@alexcjohnson
Copy link
Collaborator

Good point! I don't see any way currently to turn this behavior off. Seems like the options are:

  • add something like false to the acceptable options for scaleanchor so you can explicitly override a default set by having an image
  • add an attribute to image traces to disable automatic scaleanchor - ie giving the image trace an attribute like squarepixels which would default to true but you can set it to false in which case that image would not contribute to axHasImage.

The second might be more discoverable in the documentation, but it's less direct and if you have multiple images you'd need to set this on all of them. The first requires you to figure out that the constraint is specified on the Y axis and that an explicit false will remove it, but you only have to do this once (per Y axis) and would generalize if we ever add any other conditions that automatically set a constraint.

So I'd lean toward the first, plus a note somewhere in the docs for image trace about this setting in the Y axis.

@josephernest
Copy link
Author

This would be great @alexcjohnson! What do you think @lvlte?

@lvlte
Copy link
Contributor

lvlte commented Aug 18, 2023

Yes I would go for the first option too. I think I will make a PR this weekend or next week.

@josephernest
Copy link
Author

josephernest commented Aug 22, 2023

Thanks for the pull request @lvlte and for the merge!
Do you think it will be included for v2.25.3 @archmoj?

@archmoj
Copy link
Contributor

archmoj commented Aug 22, 2023

Thanks for the pull request @lvlte and for the merge! Do you think it will be included for v2.25.3 @archmoj?
@josephernest New features would be included in the next minor.
We would possibly release 2.26.0 this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature something new
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants