问题描述
我的单元格的数值可以是0到 Integer.MAX_VALUE
之间的任何值。我想相应地对这些单元格进行颜色编码。
I have cells for whom the numeric value can be anything between 0 and Integer.MAX_VALUE
. I would like to color code these cells correspondingly.
如果值= 0,则r = 0.如果值为 Integer.MAX_VALUE
,则r =但是它们之间的值怎么样?
If the value = 0, then r = 0. If the value is Integer.MAX_VALUE
, then r = 255. But what about the values in between?
我想我需要一个函数,其限制为x => Integer.MAX_VALUE
是255.这是什么功能?或者有更好的方法吗?
I'm thinking I need a function whose limit as x => Integer.MAX_VALUE
is 255. What is this function? Or is there a better way to do this?
我可以做(值/(Integer.MAX_VALUE / 255))
但这将导致许多低值为零。所以也许我应该用日志函数来做。
I could just do (value / (Integer.MAX_VALUE / 255))
but that will cause many low values to be zero. So perhaps I should do it with a log function.
我的大多数值都在[0,10,000]范围内。所以我想强调那里的差异。
Most of my values will be in the range [0, 10,000]. So I want to highlight the differences there.
推荐答案
我认为日志适合对此有好处,但看结果,我不太确定。
I figured a log fit would be good for this, but looking at the results, I'm not so sure.
然而,非常适合:
I从那开始,结果是:
I started with that, and ended up with:
r(x) = floor(((11.5553 * log(14.4266 * (x + 1.0))) - 30.8419) / 0.9687)
有趣的是,事实证明这几乎相同结果给Artelius的答案:
Interestingly, it turns out that this gives nearly identical results to Artelius's answer of:
r(x) = floor(255 * log(x + 1) / log(2^31 + 1)
恕我直言,你最好使用0-10000的分割功能和10000-2 ^ 31。
IMHO, you'd be best served with a split function for 0-10000 and 10000-2^31.
这篇关于比例数为< = 255?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!