Closed ignacio82 closed 9 years ago
A "value"
treemap always considers the color palette to be diverging. So one way to start with red is this dirty trick:
library(RColorBrewer)
RdYlGn <- brewer.pal(9, "RdYlGn")
treemap(business,
index=c("NACE1", "NACE2"),
vSize="employees",
vColor="employees.growth",
type="value",
palette=c(rep("#000000", 8), RdYlGn))
Another option is to use a "manual"
treemap:
treemap(business,
index=c("NACE1", "NACE2"),
vSize="employees",
vColor="employees.growth",
type="manual",
palette="RdYlGn",
range=c(00000,800000))
The downside is of course that you'll have to specify a range
.
Please let me know if this solution is satisfying. If you want, I can relax the diverging-palette-constraint for "value"
treemaps with another argument. This may be useful for https://github.com/timelyportfolio/d3treeR.
Manual + d3treeR works but I think is not perfect. In this example, "2" should be yellow:
It would be great to be able to specify minColor
, midColor
, and maxColor
like in googleVis::gvisTreeMap
Thanks!
I'm not sure what you mean.
The underlying thought of "value"
treemap is that 0
is always the midColorValue
to speak in googleVis language. The minColorValue
and maxColorValue
are -max(abs(values))
and max(abs(values))
respectively.
So if one could specify minColor
, midColor
and maxColor
, how would you like to map them to the range of values? In your example I think it is sufficient to add midColorValue
, and set it to 2 instead of 0, isn't it?
exactly, midColorValue
would be yellow and =2 instead of 0
Ok, but what values do you want to map to the minColor
and maxColor
? I think there are three options:
-max(abs(values))
and max(abs(values))
, like the current behaviour of the "value"
typemin(values)
and max(values)
range
argument for the "manual"
typeoption 2 or 3. I guess 3 is the most flexible one
It is possible now! Besides the range
argument, which now only specifies the range of the legend colors, there is a mapping
argument.
Please let me know if it works as you expected.
Thanks @mtennekes ! Could you share an example?
Thanks!
I would like the color palette in the following example to start in red instead of yellow
Is that possible?