我如何使用Plotly Treemap覆盖单个盒子颜色
我正在创建一个带有Plitly的Treemap,该treemap按回购中的大小显示文件,并为目录嵌套。我想根据自己的任意规则分配颜色。例如,“以测试_
开头的文件是红色的”或“二进制文件为蓝色”。我不使用dataframe,所以我调用treemap()
这样:
fig = px.treemap(names=names, ids=ids, parents=parents, values=values, ...)
我希望通过一个明确具有每个节点的颜色的匹配数组。 treemap()
params color
和iNCETE_COLOR_MAP
似乎无法正常工作?有没有办法指定每个盒子的颜色?
I'm creating a treemap with Plotly that shows files in a repo by their size, with nesting for the directories. I'd like to assign colors based on my own arbitrary rules. For example "files that start with test_
are red" or "binary files are blue". I'm not using a dataframe so I call treemap()
like this:
fig = px.treemap(names=names, ids=ids, parents=parents, values=values, ...)
I was hoping to pass in a matching array that explicitly had the color of every node. The treemap()
params color
and discrete_color_map
don't seem to work that way? Is there a way to specify the color of every box?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
IDS
和color
进行此操作,然后具有color_discrete_map
覆盖每个盒子的颜色。此示例基于我的用例有点奇怪,但它有效:它产生:
You can do this with
ids
andcolor
and then havecolor_discrete_map
override the color of every box. This example is a little weird based on my use case, but it works:which produces: