r sankeynetwork d3.scaleordinal() - 为什么最后两个节点的颜色不变

发布于 2025-01-25 20:48:17 字数 926 浏览 0 评论 0原文

我正在手动在Sankey图中手动更改条形的颜色,但是对于最后三个类别,颜色不会根据新的Color_Scale和“黄色”分配给最后三个类别的所有类别。

''

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))

'''

可以在此处下载数据: https://drive.google.com/file/d/1hpq-pvw89hsvylrla0anqdfb-orjbjiz/view?usp = sharing

图形和数据看起来像这样: [在这里输入图像描述] [1] [1]:https://i.sstatic.net/2eqaf.png

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.sstatic.net/2EqAF.png

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文