简体   繁体   English

在R中为树图创建对数发散调色板

[英]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). 我的数据跨越几个数量级(-10e-9至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? 有没有办法在R中设置具有以下特征的调色板?

  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). 发散,负值从红色(-10e-9)变为绿色(0),正值从黄色(0)变为蓝色(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. 我尝试对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. 不幸的是,“手动”树图假定线性vColor标度。

I will add an argument to change legend break labels. 我将添加一个参数以更改图例中断标签。 For the time being, you could modify the labels in the plotted grid object. 目前,您可以在绘制的网格对象中修改标签。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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