简体   繁体   中英

Create a logarithmic diverging color palette for a treemap in R

I have data that span several orders of magnitude (-10e-9 to 10e+9). I am displaying them on a value treemap, but I want more control over the colors used.

I assume I would want to use the "manual" treemap type, but I have not had much luck with the palette selection / specification. Is there a way to set up a palette in R with the following characteristics?

  1. Diverging, with negative values going from from red (-10e-9) to green (0) and positive values going from yellow (0) to blue (10e+9).

  2. Logarithmic scaling so that the data points closer to zero don't all get assigned nearly-identical colors.

I tried using natural logs of the data for vColor. This produced the visual effect I wanted, but now my legend is displaying log-transformed values, not the original values.

I think you're on the right track. Unfortunately, "manual" treemap assume linear vColor scales.

I will add an argument to change legend break labels. For the time being, you could modify the labels in the plotted grid object.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM