在JFreeChart中设置直方图中断 [英] Setting histogram breaks in JFreeChart
问题描述
我正在使用JFreeChart通过使用我的数据填充HistogramDataset对象并使用ChartFactory.createHistogram()来绘制直方图。但是,到目前为止,我还没有在文档中找到有关如何设置直方图中断的任何内容。我错过了什么,或JFreeChart nog是否提供此功能?
I am using JFreeChart to draw histograms by filling a HistogramDataset object with my data and using the ChartFactory.createHistogram(). However, So far I have not been able to find anything in the documentation on how to set the breaks of the histogram. Am I missing anything, or does JFreeChart nog offer this functionality?
为说明我对休息的意思,请参阅以下两个直方图,这些直方图是根据相同数量的相同数据生成的箱子,但有不同的休息时间。请注意两个直方图之间的分布形状是如何非常不同的,因此能够控制中断非常重要。
To illustrate what I mean with breaks, see the following two histograms generated from the same data with identical number of bins, but with different breaks. Note how the shapes of the distribution are very different between the two histograms, therefore it is important to be able to control the breaks.
推荐答案
SimpleHistogramBin
是一个这是一个很好的选择,因为它允许指定bin边界。将生成的箱子添加到 SimpleHistogramDataset
与 ChartFactory.createHistogram()
一起使用。根据需要调用 setAdjustForBinSize()
。
SimpleHistogramBin
is a good choice for this, as it allows specifying the bin bounds. Add the resulting bins to a SimpleHistogramDataset
for use with ChartFactory.createHistogram()
. Invoke setAdjustForBinSize()
as needed.
SimpleHistogramDataset data = new SimpleHistogramDataset("Time");
for (int i = 10; i < 70; i += 10) {
data.addBin(new SimpleHistogramBin(i, i + 10, true, false));
}
data.setAdjustForBinSize(false);
这篇关于在JFreeChart中设置直方图中断的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!