0

I am working on manually changing the color of the bars in a sankey diagram, but for the last three categories, the colors do not vary according to the new color_scale and "yellow" is assigned to all of the three last categories.

'''

color_scale <- 'd3.scaleOrdinal().
                  range(["gainsboro","dimgray", "black" , 
"darkred","red","tomato", "lightsalmon", 
"royalblue","blue",  "midnightblue", "deepskyblue", 
"yellow", "green","red"])'
sankeyNetwork(Links = resparking$links, Nodes = resparking$nodes, Source = "source",
              Target = "target", Value = "value", NodeID = "name",
              units = "Number of Houses", 
              fontSize = 20, nodeWidth = 30, 
              colourScale = JS(color_scale))

'''

The data can be downloaded here: https://drive.google.com/file/d/1hPq-PvW89hsVylrLA0anqDFB-OrjBJIz/view?usp=sharing

The graph and data look like this: [enter image description here][1] [1]: https://i.stack.imgur.com/2EqAF.png

  • It's easier to help you if you provide a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. Share data in a `dput()` format rather than an image. – MrFlick May 03 '22 at 18:26
  • Thank you! I added a download link for the dataset. – Abby Dunlap May 03 '22 at 23:18

0 Answers0