本文整理汇总了Java中org.jfree.data.statistics.HistogramDataset类的典型用法代码示例。如果您正苦于以下问题:Java HistogramDataset类的具体用法?Java HistogramDataset怎么用?Java HistogramDataset使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
HistogramDataset类属于org.jfree.data.statistics包,在下文中一共展示了HistogramDataset类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createCellAreaHistogram
import org.jfree.data.statistics.HistogramDataset; //导入依赖的package包/类
/**
* TODO Documentation
*
* @param dataset
* @return
*/
private JFreeChart createCellAreaHistogram(HistogramDataset dataset) {
String areaUnit = "μm^2"; // Set default value
if (forest != null) {
areaUnit = forest.getMetaxml().getAllCellsInMetaXML().get(0).getAreaUnit();
}
final JFreeChart chart = ChartFactory.createHistogram(
"Cell Area Distribution",
String.format("Area [%s]", areaUnit),
"Occurrence [-]",
dataset,
PlotOrientation.VERTICAL,
true,
true,
false);
styleChart(chart);
return chart;
}
示例2: histogramChart
import org.jfree.data.statistics.HistogramDataset; //导入依赖的package包/类
/**
* Création et affichage d'un histogramme avec JFreeChart
* @param listIn
*/
public static void histogramChart(List<Double> listIn, String listName) {
double tabIn[] = new double[listIn.size()];
for (int i = 0; i < listIn.size(); i++) {
tabIn[i] = listIn.get(i);
}
// Création des datasets
HistogramDataset dataset = new HistogramDataset();
dataset.setType(HistogramType.RELATIVE_FREQUENCY);
dataset.addSeries(listName, tabIn, 200);
// Création de l'histogramme
JFreeChart chart = ChartFactory.createHistogram("", null, null, dataset,
PlotOrientation.VERTICAL, true, true, false);
ChartFrame frame = new ChartFrame("Spatial Data Quality", chart);
frame.pack();
frame.setVisible(true);
}
示例3: createDataset
import org.jfree.data.statistics.HistogramDataset; //导入依赖的package包/类
/**
* Creates dataset for histogram.
*
* @param table
* table with data
* @param column
* column of which you want the data
* @param bin
* for dividing the output in certain amount of parts
* @return dataset
*/
public static HistogramDataset createDataset(final Table table,
final String column, final int bin) {
HistogramDataset dataSet = new HistogramDataset();
// Convert table to usable form of data
double[] data = hist(table, column);
// Calculate maximum value that appears in data
// Calculate minimum value that appears in data
double max = data[0];
double min = data[0];
for (int i = 0; i < data.length; i++) {
if (data[i] > max) {
max = data[i];
}
if (data[i] < min) {
min = data[i];
}
}
dataSet.addSeries("Hist", data, bin, 0, max);
return dataSet;
}
示例4: updateHistograms
import org.jfree.data.statistics.HistogramDataset; //导入依赖的package包/类
private void updateHistograms() {
dataSet = new HistogramDataset();
plotRenderer = new ColoredXYBarRenderer();
plotRenderer.setShadowVisible(false);
plotRenderer.setBarPainter(new StandardXYBarPainter());
plot = new XYPlot(dataSet, domainAxis, rangeAxis, plotRenderer);
for (HistogrammVisualization vis : activeHistograms) {
vis.addDataSeries(dataSet);
vis.addMarkers(plot);
}
plot.configureDomainAxes();
plot.configureRangeAxes();
chart = new JFreeChart(plot);
chartPanel.setChart(chart);
chartPanel.restoreAutoBounds();
}
示例5: createCellFluorescencesHistogram
import org.jfree.data.statistics.HistogramDataset; //导入依赖的package包/类
/**
* Creates the {@link JFreeChart} that this chart shows.
*
* @param dataset
* The {@link HistogramDataset} that backs the created
* {@link JFreeChart}.
* @param channel
* the identifier of the fluorescence channel
*
* @return A {@link JFreeChart} instance that is shown by this chart.
*/
private JFreeChart createCellFluorescencesHistogram(HistogramDataset dataset, String channel) {
String fluorescenceUnit = "au"; // Set default value
if (forest != null) {
fluorescenceUnit = forest.getMetaxml().getAllCellsInMetaXML().get(0).getFluorescenceUnit();
}
final JFreeChart chart = ChartFactory.createHistogram(
channel +"-Fluorescence Distribution",
String.format("Fluorescence [%s]", fluorescenceUnit),
"Occurrence [-]",
dataset,
PlotOrientation.VERTICAL,
true,
true,
false);
styleChart(chart);
return chart;
}
示例6: createCellLengthHistogram
import org.jfree.data.statistics.HistogramDataset; //导入依赖的package包/类
/**
* TODO Documentation
*
* @param dataset
* @return
*/
private JFreeChart createCellLengthHistogram(HistogramDataset dataset) {
String lengthUnit = "μm"; // Set default value
if (forest != null) {
lengthUnit = forest.getMetaxml().getAllCellsInMetaXML().get(0).getLengthUnit();
}
final JFreeChart chart = ChartFactory.createHistogram(
"Cell length distribution",
String.format("Length [%s]", lengthUnit),
"Occurrence [-]",
dataset,
PlotOrientation.VERTICAL,
true,
true,
false);
styleChart(chart);
return chart;
}
示例7: testEquals
import org.jfree.data.statistics.HistogramDataset; //导入依赖的package包/类
/**
* Confirm that the equals method can distinguish all the required fields.
*/
public void testEquals() {
double[] values = {1.0, 2.0, 3.0, 4.0, 6.0, 12.0, 5.0, 6.3, 4.5};
HistogramDataset d1 = new HistogramDataset();
d1.addSeries("Series 1", values, 5);
HistogramDataset d2 = new HistogramDataset();
d2.addSeries("Series 1", values, 5);
assertTrue(d1.equals(d2));
assertTrue(d2.equals(d1));
d1.addSeries("Series 2", new double[] {1.0, 2.0, 3.0}, 2);
assertFalse(d1.equals(d2));
d2.addSeries("Series 2", new double[] {1.0, 2.0, 3.0}, 2);
assertTrue(d1.equals(d2));
}
示例8: testAddSeries2
import org.jfree.data.statistics.HistogramDataset; //导入依赖的package包/类
/**
* Another check for the addSeries() method.
*/
public void testAddSeries2() {
double[] values = {0.0, 1.0, 2.0, 3.0, 4.0, 5.0};
HistogramDataset hd = new HistogramDataset();
hd.addSeries("S1", values, 5);
assertEquals(0.0, hd.getStartXValue(0, 0), EPSILON);
assertEquals(1.0, hd.getEndXValue(0, 0), EPSILON);
assertEquals(1.0, hd.getYValue(0, 0), EPSILON);
assertEquals(1.0, hd.getStartXValue(0, 1), EPSILON);
assertEquals(2.0, hd.getEndXValue(0, 1), EPSILON);
assertEquals(1.0, hd.getYValue(0, 1), EPSILON);
assertEquals(2.0, hd.getStartXValue(0, 2), EPSILON);
assertEquals(3.0, hd.getEndXValue(0, 2), EPSILON);
assertEquals(1.0, hd.getYValue(0, 2), EPSILON);
assertEquals(3.0, hd.getStartXValue(0, 3), EPSILON);
assertEquals(4.0, hd.getEndXValue(0, 3), EPSILON);
assertEquals(1.0, hd.getYValue(0, 3), EPSILON);
assertEquals(4.0, hd.getStartXValue(0, 4), EPSILON);
assertEquals(5.0, hd.getEndXValue(0, 4), EPSILON);
assertEquals(2.0, hd.getYValue(0, 4), EPSILON);
}
示例9: asChart
import org.jfree.data.statistics.HistogramDataset; //导入依赖的package包/类
/** Return the JFreeChart with this histogram, and as a side effect, show it in a JFrame
* that provides the means to edit the dimensions and also the plot properties via a popup menu. */
public JFreeChart asChart(final boolean show) {
double[] d = new double[this.size()];
int i = 0;
for (Number num : this.values()) d[i++] = num.doubleValue();
HistogramDataset hd = new HistogramDataset();
hd.setType(HistogramType.RELATIVE_FREQUENCY);
String title = "Histogram";
hd.addSeries(title, d, d.length);
JFreeChart chart = ChartFactory.createHistogram(title, "", "", hd,
PlotOrientation.VERTICAL, false, false, false);
setTheme(chart);
if (show) {
JFrame frame = new JFrame(title);
frame.getContentPane().add(new ChartPanel(chart));
frame.pack();
frame.setVisible(true);
}
return chart;
}
示例10: getDataSet
import org.jfree.data.statistics.HistogramDataset; //导入依赖的package包/类
private HistogramDataset getDataSet() {
HistogramDataset dataset = new HistogramDataset();
dataset.setType(HistogramType.FREQUENCY);
List<Double> values =
CollectionUtils.mapNullRemoves(
download.getAllValidConnections(),
new CollectionUtils.Function<BitTorrentConnection, Double>() {
public Double evaluate(BitTorrentConnection connection) {
BitField bitField = connection.getRemoteBitField();
if (bitField == null || !connection.isOpen()) {
return null;
}
return 100.0 * bitField.getAvailablePieceCount() / bitField.getPieceCount();
}
});
dataset.addSeries("Completion", CollectionUtils.toArray(values), 50, 0.0, 100.0);
return dataset;
}
示例11: createChart
import org.jfree.data.statistics.HistogramDataset; //导入依赖的package包/类
private JFreeChart createChart(HistogramDataset dataset) {
JFreeChart chart = ChartFactory.createHistogram(
"Remote Peer Completion",
"Completion %",
"Peers",
dataset,
PlotOrientation.VERTICAL,
false, false, false);
chart.setBackgroundPaint(Color.white);
XYPlot plot = chart.getXYPlot();
plot.setBackgroundPaint(Color.lightGray);
plot.setDomainGridlinePaint(Color.white);
plot.setRangeGridlinePaint(Color.white);
plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
plot.setRangeCrosshairVisible(true);
plot.getDomainAxis().setAutoRange(false);
plot.getDomainAxis().setRange(0.0, 100.0);
return chart;
}
示例12: createHistogramDataset
import org.jfree.data.statistics.HistogramDataset; //导入依赖的package包/类
/**
* Creates a {@link HistogramDataset} for this {@link Attribute}.
*
* @param exampleSet
* @return
*/
private HistogramDataset createHistogramDataset(final ExampleSet exampleSet) {
HistogramDataset dataset = new HistogramDataset();
double[] array = new double[exampleSet.size()];
int count = 0;
for (Example example : exampleSet) {
double value = example.getDataRow().get(getAttribute());
// don't use missing values because otherwise JFreeChart tries to plot them too which
// can lead to false histograms
if (!Double.isNaN(value)) {
array[count++] = value;
}
}
// add points to data set (if any)
if (count > 0) {
// truncate array if necessary
if (count < array.length) {
array = Arrays.copyOf(array, count);
}
dataset.addSeries(getAttribute().getName(), array, Math.min(array.length, MAX_BINS_HISTOGRAM));
}
return dataset;
}
示例13: createHistogramDataset
import org.jfree.data.statistics.HistogramDataset; //导入依赖的package包/类
/**
* Creates a {@link HistogramDataset} for this {@link Attribute}.
*
* @param exampleSet
* @return
*/
private HistogramDataset createHistogramDataset(ExampleSet exampleSet) {
HistogramDataset dataset = new HistogramDataset();
double[] array = new double[exampleSet.size()];
int count = 0;
for (Example example : exampleSet) {
double value = example.getDataRow().get(getAttribute());
// don't use missing values because otherwise JFreeChart tries to plot them too which
// can lead to false histograms
if (!Double.isNaN(value)) {
array[count++] = value;
}
}
// add points to data set (if any)
if (count > 0) {
// truncate array if necessary
if (count < array.length) {
array = Arrays.copyOf(array, count);
}
dataset.addSeries(getAttribute().getName(), array, Math.min(array.length, MAX_BINS_HISTOGRAM));
}
return dataset;
}
示例14: testEquals
import org.jfree.data.statistics.HistogramDataset; //导入依赖的package包/类
/**
* Confirm that the equals method can distinguish all the required fields.
*/
public void testEquals() {
final double[] values = {1.0, 2.0, 3.0, 4.0, 6.0, 12.0, 5.0, 6.3, 4.5};
final HistogramDataset d1 = new HistogramDataset();
d1.addSeries("Series 1", values, 5);
final HistogramDataset d2 = new HistogramDataset();
d2.addSeries("Series 1", values, 5);
assertTrue(d1.equals(d2));
assertTrue(d2.equals(d1));
}
示例15: testBins
import org.jfree.data.statistics.HistogramDataset; //导入依赖的package包/类
/**
* Some checks that the correct values are assigned to bins.
*/
public void testBins() {
double[] values = {1.0, 2.0, 3.0, 4.0, 6.0, 12.0, 5.0, 6.3, 4.5};
HistogramDataset hd = new HistogramDataset();
hd.addSeries("Series 1", values, 5);
assertEquals(hd.getYValue(0, 0), 3.0, EPSILON);
assertEquals(hd.getYValue(0, 1), 3.0, EPSILON);
assertEquals(hd.getYValue(0, 2), 2.0, EPSILON);
assertEquals(hd.getYValue(0, 3), 0.0, EPSILON);
assertEquals(hd.getYValue(0, 4), 1.0, EPSILON);
}