“绘图”大范围内的一个数

发布于 2024-12-04 03:52:14 字数 1399 浏览 2 评论 0原文

简而言之,我正在尝试制作一个条形图(使用 GWT 的 HTML5 画布包装器),它将显示给定值的合理内容,无论图表底部和顶部的实际值是多少。我假设最好的方法是对数,但我完全接受任何其他解决方案。

假设:

  • 我们的垂直“条”,高 200 像素,宽 35 像素。

  • 我们正在显示一个“站点”及其父“区域”。这些单位是功率单位(例如 kW、MW、GW)。

  • “区域”的范围为 1 kW 至 55.19 GW。平均值为27.6 MW。

  • 该区域内大约 95% 的站点比 55 GW 更接近 1 W,但前 5% 的站点明显偏离平均值。

  • 第一个站点的值为12.67 MW第二个站点的值为192.21 kW

显然,第二个站点甚至不会在线性图上注册,而第一个站点的注册值非常低。

我怎样才能让这个栏更有用?例如,我希望影响该地区平均值的前 5% 的网站仅代表总条形的一小部分 (5%),而其他 95% 的网站应代表 95%。

问题的概念图

条形图下部区域的线是区域平均线,而整个条形图代表最小值 (底部)到最大(顶部)。

当前使用 log10 的 Java 代码:

// BAR_GRAPH_WIDTH = 36, BAR_GRAPH_HEIGHT = 200
// regionNsp (MW): [min=0.0, max=55192.8, avg=27596.5] 
// siteNsp (MW) = 187.18
DrawingArea canvas = new DrawingArea(BAR_GRAPH_WIDTH, BAR_GRAPH_HEIGHT);
Rectangle bgRect = new Rectangle(1, 0, BAR_GRAPH_WIDTH - 1, BAR_GRAPH_HEIGHT); // backgound bar
bgRect.setFillColor("white");
canvas.add(bgRect);
int graphSize = (int)(BAR_GRAPH_HEIGHT / Math.log10(regionNsp.getMax()));
int siteHeight = (int)Math.log10(siteNsp - regionNsp.getMin()) * graphSize;
Rectangle valueRect = new Rectangle(1, BAR_GRAPH_HEIGHT-siteHeight, 35, siteHeight);
valueRect.setFillColor("lightgreen");
canvas.add(valueRect);

In short, I'm trying to make a bar (using GWT's wrapper for HTML5 canvas) that will show something reasonable for a given value, no matter what the value of the bottom and top of the chart actually are. I'm assuming the best approach is logarithmic, but I'm completely open to any other solution.

Assumptions:

  • Our "bar" vertical, measuring 200 pixels high, 35 pixels wide.

  • We're showing a "site" versus it's parent "region". The units are ones of power (e.g. kW, MW, GW).

  • The "region" has a range of 1 kW to 55.19 GW. The average value is 27.6 MW.

  • Approximately 95% of sites within the region are much closer to 1 W than 55 GW, but the top 5% skew the average significantly.

  • The first site has a value of 12.67 MW. The second site has a value of 192.21 kW.

Obviously the second site wouldn't even register on a linear graph, while the first would register very low.

How can I make this bar more useful? For example, I'd like the top 5% of sites that skew the region's average to represent only a small portion (5%) of the total bar, while the other 95% should represent 95%.

Conceptual Image of Problem

The line in the lower area of the bar is the region average line, while the entire bar represents Minimum (bottom) to Maximum (top).

Current Java code using log10:

// BAR_GRAPH_WIDTH = 36, BAR_GRAPH_HEIGHT = 200
// regionNsp (MW): [min=0.0, max=55192.8, avg=27596.5] 
// siteNsp (MW) = 187.18
DrawingArea canvas = new DrawingArea(BAR_GRAPH_WIDTH, BAR_GRAPH_HEIGHT);
Rectangle bgRect = new Rectangle(1, 0, BAR_GRAPH_WIDTH - 1, BAR_GRAPH_HEIGHT); // backgound bar
bgRect.setFillColor("white");
canvas.add(bgRect);
int graphSize = (int)(BAR_GRAPH_HEIGHT / Math.log10(regionNsp.getMax()));
int siteHeight = (int)Math.log10(siteNsp - regionNsp.getMin()) * graphSize;
Rectangle valueRect = new Rectangle(1, BAR_GRAPH_HEIGHT-siteHeight, 35, siteHeight);
valueRect.setFillColor("lightgreen");
canvas.add(valueRect);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

终难遇 2024-12-11 03:52:14

考虑对数标度,并在远远超出总体中任何其他值的极高值处进行中断。有关条形和轴中断的示例,请参阅:http://tomhopper.files.wordpress.com/2010/08/bar-chart-natural-axis-split1.png

Consider logarithmic scale with a break for extremely high values that are far beyond any others in the population. For an example of a break in the bars and axis, see: http://tomhopper.files.wordpress.com/2010/08/bar-chart-natural-axis-split1.png

小鸟爱天空丶 2024-12-11 03:52:14

我承认我对 GWT 了解不多,所以我的回答是基于如何在纸笔图表上显示您的值。这个答案是你已经回答了你自己的问题 - 使用日志。范围从1000到552亿,平均在27600000左右,取(公基10)对数后,变成约3到11,平均在7.4左右。

需要注意的是,你在“合理性”中获得的东西,你却在观点上失去了意义。采用分贝标度,它是基于(公共基数 10)对数的。 80 分贝的声音和 85 分贝的声音之间的差异似乎并没有太大的变化,只是第二个声音的能量三倍

I admit that I don't know much about GWT, so I'm answering on the basis of how would I show your values on a paper-and-pencil graph. That answer is that you've answered your own question - use logs. The range from 1000 to 55200000000 with an average around 27600000, after taking (common base 10) logs, becomes about 3 to 11, with the average around 7.4.

The caveat is that what you gain in "reasonableness" you do loose in perspective. Take the decibel scale, which is (common base 10) log based. The difference between an 80 decibel sound and an 85 decibel sound doesn't seem like a big change, except that the second is three times more energetic.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文