-
Notifications
You must be signed in to change notification settings - Fork 626
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
Equal scaling of axes not working #218
Comments
Here's a solution I came up with: https://github.com/ropensci/plotly/blob/baobao-equal_axes/R/ggplotly.R#L771-785 # fixed coordinates: if the coordinates ratio is not NULL, then
# we make the size of the plot according to the specified ratio
# note: we set the biggest dimension to 600
if (!is.null(p$coordinates$ratio)){
x.range <- range(built[[2]]$ranges[[1]]$x.major_source, na.rm = TRUE)
y.range <- range(built[[2]]$ranges[[1]]$y.major_source, na.rm = TRUE)
y.x.ratio <- (y.range[2] - y.range[1])/(x.range[2] - x.range[1])
if (y.x.ratio > 1){
layout$height <- 600
layout$width <- layout$height*(1/p$coordinates$ratio)*(1/y.x.ratio)
} else{
layout$width <- 600
layout$height <- layout$height*(1/p$coordinates$ratio)*y.x.ratio
}
} What I did was if the user specified a coordinate ratio, the height and width in layout would be in that ratio. I was not sure how big the dimensions could get so I set the biggest dimension (whether it's x or y) to 600. The new images look like this. Questions, suggestions, comments welcome! |
that seems like the right approach! |
Closing in favor of #342 |
This is one of the unsupported features from the cookbook, see Issue #161.
There's a problem with setting the scaling of the axes to an equal ratio, with one visual unit being representing the same numeric unit on both axes. There's also a problem when I set them to ratios other than 1:1.
Cookbook:
Plotly:
Cookbook:
Plotly:
cc @cpsievert @chriddyp @mkcor
The text was updated successfully, but these errors were encountered: