Closed
Description
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?
Activity
[-]Remove the scaleanchor constrain applied by default on axes having an image trace[/-][+]Remove the scaleanchor constrain on axes having an image trace[/+]alexcjohnson commentedon Aug 17, 2023
Good point! I don't see any way currently to turn this behavior off. Seems like the options are:
false
to the acceptable options forscaleanchor
so you can explicitly override a default set by having an imageimage
traces to disable automaticscaleanchor
- ie giving the image trace an attribute likesquarepixels
which would default totrue
but you can set it tofalse
in which case that image would not contribute toaxHasImage
.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 commentedon Aug 18, 2023
This would be great @alexcjohnson! What do you think @lvlte?
lvlte commentedon 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 commentedon 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 commentedon Aug 22, 2023