Skip to content

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

Closed

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

Activity

  1. cpsievert commented on Oct 24, 2018

    @cpsievert
    Collaborator

    Huh, weird, this doesn't seem to be a problem using the master branch on GitHub -- would you mind trying devtools::install_github("ropensci/plotly") and/or report your devtools::session_info()?

  2. shosaco commented on Oct 24, 2018

    @shosaco
    Author

    That's true, it is working properly with the development version. Thank you!

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