java jfreechart中的直方图

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2214755/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 20:05:41  来源:igfitidea点击:

histogram in jfreechart

javajfreechart

提问by klaus johan

I'm trying to use JfreeChartto create a chart for the histogram of an image , but I don't fully understand how to provide the input data for the histogram .The function I am suppose to use is this:

我正在尝试使用JfreeChart为图像的直方图创建图表,但我不完全了解如何为直方图提供输入数据。我想使用的函数是:

addSeries(java.lang.Comparable key, double[] values, int bins) 

I find that documentation is really unclear. I have a 256-element array filled with the number of pixels of each intensity which I want to be able to use as an input, but I don't know how. Has someone encountered this problem before ?

我发现文档真的不清楚。我有一个 256 元素的数组,其中填充了我希望能够用作输入的每个强度的像素数,但我不知道如何使用。以前有人遇到过这个问题吗?

回答by Binary Nerd

Examples loading data into a JFreeChart HistogramDataset:

将数据加载到 JFreeChart HistogramDataset 的示例:

HistogramDataset dataset = new HistogramDataset();
dataset.setType(HistogramType.RELATIVE_FREQUENCY);
dataset.addSeries("H1", double[], 20);

HistogramDataset dataset = new HistogramDataset();
double[] values = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0};
dataset.addSeries("H1", values, 10, 0.0, 10.0);