custom colors in R Plotly

前端 未结 4 2023
没有蜡笔的小新
没有蜡笔的小新 2021-01-12 00:57

I\'m currently a beginner in Plotly and have a problem I can\'t seem to solve. I have my plotly stacked bar chart but I don\'t know how to color each individual category. I

4条回答
  •  有刺的猬
    2021-01-12 01:58

    I came across this question today because I was trying to define colors for every individual marker and struggling. The answer came from one of the other answers, but that answer said it didn't work for this question, but it did for mine.

    Here is a gist with and MRE: https://gist.github.com/bhive01/d4821f6d73ea0f428767d9bb68fdd404

    Essentially, rather than define colors with color and/or colors, you use marker = list(color = ~color). This assumes you have data like mine where every point has a color. This was critical for me because when I used color = ~Hex, colors = ~Hex the colors were used, but the data got sorted and the colors did not match their correct marker.

提交回复
热议问题