histogram in jfreechart
Asked Answered
K

1

9

I'm trying to use JfreeChart to 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:

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 ?

Kaftan answered 6/2, 2010 at 21:13 Comment(0)
T
8

Examples loading data into a 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);
Tenet answered 6/2, 2010 at 21:46 Comment(2)
You might need to check if the HistogramDataset is binning the data for you. Your array sounds like it is pre-binned.Tenet
Thanks @AlbertCheng, i've removed the link, i can't find an good replacement.Tenet

© 2022 - 2024 — McMap. All rights reserved.