When using a colorscale on a treemap trace (without providing a root) the container is shown in black :
library(plotly)
labels = c("A1", "A2", "A3", "A4", "A5", "B1", "B2")
parents = c("", "A1", "A2", "A3", "A4", "", "B1")
values = c("11", "12", "13", "14", "15", "20", "30")
fig <- plot_ly(
type="treemap",
labels=labels,
parents=parents,
values=values,
marker=list(colorscale='Reds'))
fig
Example taken from here: Treemap Charts | R | Plotly
I’d like to change it to white .
In the python plotly library there is a root_color
argument to do so:
fig.update_traces(root_color="lightgrey")
see: Treemap Charts | Python | Plotly
Is there any workaround to achive this in R? I can’t find the according option.
I know it’s late, but for anyone still looging for this, treemaps on plotly does have a color root parameter (root = list(color = …)). You could try it first and see if it works for you, but it didn’t work for me
My turnaround was setting the color palette inside the parameter treemapcolorway inside the layout parameter:
library(plotly)
labels = c("A1", "A2", "A3", "A4", "A5", "B1", "B2")
parents = c("", "A1", "A2", "A3", "A4", "", "B1")
values = c("11", "12", "13", "14", "15", "20", "30")
fig <- plot_ly(
type="treemap",
labels=labels,
parents=parents,
values=values) %>%
layout(treemapcolorway='Reds')
fig
@naruhiko thanks for your reply.
It can be seen in the docs , that the default root color for a treemap using treemapcolorway
is white.
However, I was specifically asking for a treemap using a colorscale. Your above example ignores the provided colorscale and uses the default colors.
Here you can find the related GitHub issue:
opened 01:59PM - 09 Sep 21 UTC
When using a colorscale on a treemap trace (without providing a root) the contai… ner is shown in black:
![image](https://user-images.githubusercontent.com/36849480/132698509-bd2ce165-5d2d-42f4-8bb7-70b1dcfa996b.png)
```
library(plotly)
labels = c("A1", "A2", "A3", "A4", "A5", "B1", "B2")
parents = c("", "A1", "A2", "A3", "A4", "", "B1")
values = c("11", "12", "13", "14", "15", "20", "30")
fig <- plot_ly(
type="treemap",
labels=labels,
parents=parents,
values=values,
marker=list(colorscale='Reds'))
fig
```
Example taken from here: https://plotly.com/r/treemaps/
I'd like to change it to white.
In the python plotly library there is a `root_color` argument to do so:
`fig.update_traces(root_color="lightgrey")`
see: https://plotly.com/python/treemaps/
It would be great to have the same option in R.
Or is there any workaround to achive this?