Skip to content

Fix trace processing if number of subplots >= 10 #620

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
wants to merge 1 commit into from

Conversation

alyst
Copy link
Contributor

@alyst alyst commented Jun 3, 2016

Another fix for multi-subplots case.

Test case (single aesthetic bound to trace):

p <- ggplot( data.frame(x = rnorm(1000), y = rnorm(1000),
                   a = sample(1:20, 1000, replace=TRUE),
                   b = factor(sample(1:5, 1000, replace=TRUE))) ) +
  geom_point(aes(x=x, y=y, color=b)) + facet_wrap(~ a )

ggplotly(p)

With multiple aesthetics per trace:

p <- ggplot( data.frame(x = rnorm(1000), y = rnorm(1000),
                   a = sample(1:20, 1000, replace=TRUE),
                   b = factor(sample(1:3, 1000, replace=TRUE)),
                   c = factor(sample(1:3, 1000, replace=TRUE))) ) +
  geom_point(aes(x=x, y=y, color=b, shape=c)) + facet_wrap(~ a )

ggplotly(p)

@alyst alyst force-pushed the fix_subplot_traces branch from 28c724f to f1dbd95 Compare June 3, 2016 12:21
Also fix the split-by/discrete scales logic uncovered by the "@%&" fix
@alyst alyst force-pushed the fix_subplot_traces branch from f1dbd95 to f5852ce Compare June 3, 2016 13:16
@alyst alyst closed this Jun 3, 2016
@alyst alyst reopened this Jun 3, 2016
@alyst
Copy link
Contributor Author

alyst commented Jun 3, 2016

Previously the split_by name components were excluded from the trace name generation only if they were followed by the "@%&". That concealed the bug in estimating how many scales should be excluded (split_by scales have to be used, not the original data columns).

@alyst alyst closed this Jun 5, 2016
@alyst alyst reopened this Jun 5, 2016
@@ -55,16 +56,20 @@ layers2traces <- function(data, prestats_data, layout, p) {
trs <- Map(geom2trace, dl, paramz[i], list(p))
# are we splitting by a discrete scale on this layer?
# if so, set name/legendgroup/showlegend
isDiscrete <- names(d) %in% paste0(names(discreteScales), "_plotlyDomain")
isDiscrete <- names(d) %in% (if (length(discreteScales) > 0) { paste0(names(discreteScales), "_plotlyDomain") } else as.character())
if (length(trs) > 1 && sum(isDiscrete) >= 1) {
Copy link
Collaborator

@cpsievert cpsievert Jun 9, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alyst I'd prefer

isDiscrete <- names(d) %in% paste0(names(discreteScales), "_plotlyDomain") %||% ""

@cpsievert
Copy link
Collaborator

Thanks @alyst. I'm closing this, but you're contributions are much appreciated, and have been quite useful for identifying issues. Some of these ideas have been incorporated into #654.

@cpsievert cpsievert closed this Jul 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants