Skip to content

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
# 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