Skip to content

pie chart color mapping doesn't work properly when aggregating data #2468

Description

@j-andrews7

This seems to be maybe a partial regression related to #1375. Using similar code to that issue:

library(plotly)
plot_ly(mtcars[c(1,3,5), c("cyl", "drat")], labels = ~cyl, values = ~drat, type = 'pie', 
        marker = list(colors = c("cyan", "magenta", "black"))) %>%
    layout(xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
           yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE))
Image
plot_ly(mtcars[, c("cyl", "drat")], labels = ~cyl, values = ~drat, type = 'pie', 
        marker = list(colors = c("cyan", "magenta", "black"))) %>%
    layout(xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
           yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE))
Image

It seems to apply the default palette color to the first group.

Interestingly, if you bang it in there a few more times it shows (though with different order).

plot_ly(mtcars[, c("cyl", "drat")], labels = ~cyl, values = ~drat, type = 'pie', 
        marker = list(colors = c("cyan", "magenta", "black", "magenta", "magenta"))) %>%
    layout(xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
           yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE))
Image

Activity

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

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