Skip to content

Color not set properly when plotly aggregates data for pie chart #1375

@shosaco

Description

@shosaco

hi Carson,

thanks for your wonderful work. Today we discovered an issue with Plotly's pie chart coloring. Colors can be set using the marker argument:

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

2018-10-24 18_10_56-

Provided with an un-aggregated dataframe, Plotly conducts the aggregation into bins and displays the resulting pie chart. Unfortunately, coloring the slices is then not working properly:

library(plotly)
plot_ly(mtcars[, c("cyl", "drat")], labels = ~cyl, values = ~drat, type = 'pie', 
         marker = list(colors = c("yellow", "green", "red"))) %>%
     layout(xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE),
            yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE))

2018-10-24 18_11_45-

Thanks and best regards,
sandro

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions