Skip to content

Boxplot legends #345

Closed
Closed
@cpsievert

Description

@cpsievert

I'm not convinced we can/should provide legends for boxplots (see also #230). As far as I know, you can't draw multiple boxes in a single trace, so there must be a legend entry for unique x, making the legend redundant. For example, we could provide a legend for something like this:

library(plotly)
dat <- data.frame(
  cond = factor(rep(c("A", "B", "C", "D"), each = 200)), 
  col = factor(rep(c("C1", "C2"), each = 400)), 
  rating = c(rnorm(200), rnorm(200, mean = .8), rnorm(200, mean = .4), rnorm(200, mean = .2))
)
ggplot(dat, aes(x=cond, y=rating)) + 
  geom_boxplot(aes(fill=cond))

rplot01

It'd be more useful to have a legend when color/fill is nested in x, but I don't think we could do something like this in plotlyjs, right @chriddyp?

ggplot(dat, aes(x=cond, y=rating)) + 
  geom_boxplot(aes(fill=col))

rplot

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions