Skip to content

subplot() should bump xref/yref axis references #1019

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

Closed
mike-wise opened this issue May 21, 2017 · 4 comments
Closed

subplot() should bump xref/yref axis references #1019

mike-wise opened this issue May 21, 2017 · 4 comments

Comments

@mike-wise
Copy link

It is pretty well described in this StackOverflow post, and in my answer to it there: post. Do you need me to copy the information here as well?

There seem to be a number of bugs exposed there, maybe related, maybe not.

@cpsievert
Copy link
Collaborator

Shapes are automatically scaled/repositioned if you're using paper coordinates, for example:

rect <- list(
  type = "rect",
  xref = "paper", yref = "paper",
  x0 = 0.5, x1 = 0.6, 
  y0 = 0.5, y1 = 0.6
)
p1 <- layout(plot_ly(), shapes = rect)
subplot(p1, p1)

I'm not sure if it generally makes sense to something similar for non-paper coordinates.

@cpsievert cpsievert changed the title Shape positions being incorrectly calculated in subplots Automatically scale/reposition shapes for non-paper coordinates? May 21, 2017
@mike-wise
Copy link
Author

That is a good tip to generate workarounds. So thanks for that.

But people like to annotate their graphs in their "domain" coordinates, not the least because they do not actually have access to the "paper" coordinates when they are creating the plot. And if there is a well-defined mapping always available to the plotly when generating the plot, why shouldn't plotly just do the coordinate transformation? Is there a downside?

@cpsievert
Copy link
Collaborator

cpsievert commented May 22, 2017

Ok, after some more thought, I can see how this is useful. In this example, for instance, the xref/yref should be "bumped" by subplot() (but only if missing, I think).

library(plotly)
library(dplyr)

mtcars %>%
  group_by(vs) %>%
  do(
    p = plot_ly(., x = ~wt, y = ~mpg) %>% 
      layout(shapes = list(
        type = "rect", x0 = ~min(wt), x1 = ~max(wt), y0 = ~min(mpg), y1 = ~max(mpg)
      ))
  ) %>%
  subplot()

@cpsievert cpsievert changed the title Automatically scale/reposition shapes for non-paper coordinates? subplot() should bump xref/yref axis references May 22, 2017
@cpsievert
Copy link
Collaborator

Closed via #1332

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

No branches or pull requests

2 participants