本文整理汇总了Java中org.jfree.data.statistics.HistogramDataset.setType方法的典型用法代码示例。如果您正苦于以下问题:Java HistogramDataset.setType方法的具体用法?Java HistogramDataset.setType怎么用?Java HistogramDataset.setType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jfree.data.statistics.HistogramDataset
的用法示例。
在下文中一共展示了HistogramDataset.setType方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: 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;
}
示例3: 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;
}
示例4: buildHistogram
import org.jfree.data.statistics.HistogramDataset; //导入方法依赖的package包/类
private static JFreeChart buildHistogram(double[] values, int steps,
String plotTitle, String xAxis, String yAxis) {
HistogramDataset hds = new HistogramDataset();
hds.setType(HistogramType.RELATIVE_FREQUENCY);
hds.addSeries(1, values, steps);
PlotOrientation orientation = PlotOrientation.VERTICAL;
boolean show = false;
boolean toolTips = false;
boolean urls = false;
JFreeChart chart = ChartFactory.createHistogram(plotTitle, xAxis,
yAxis, hds, orientation, show, toolTips, urls);
return chart;
}
示例5: GeneratePlot
import org.jfree.data.statistics.HistogramDataset; //导入方法依赖的package包/类
public void GeneratePlot(String pngfile) throws IOException {
String modelfile = FilenameUtils.getFullPath(pngfile) + "/" + FilenameUtils.getBaseName(pngfile) + "_ModelPoints.txt";
FileWriter writer = new FileWriter(modelfile);
double[] IDObs = new double[IDEmpiricalDist.getN()];
double[] DecoyObs = new double[DecoyEmpiricalDist.getN()];
for (int i = 0; i < IDEmpiricalDist.getN(); i++) {
IDObs[i] = IDEmpiricalDist.getObs(i);
}
for (int i = 0; i < DecoyEmpiricalDist.getN(); i++) {
DecoyObs[i] = DecoyEmpiricalDist.getObs(i);
}
XYSeries model1 = new XYSeries("Incorrect matches");
XYSeries model2 = new XYSeries("Correct matches");
XYSeries model3 = new XYSeries("All target hits");
writer.write("UScore\tModel\tCorrect\tDecoy\n");
for (int i = 0; i < NoBinPoints; i++) {
model1.add(model_kde_x[i], decoy_kde_y[i]);
model2.add(model_kde_x[i], correct_kde_y[i]);
model3.add(model_kde_x[i], model_kde_y[i]);
writer.write(model_kde_x[i] + "\t" + model_kde_y[i] + "\t" + correct_kde_y[i] + "\t" + decoy_kde_y[i] + "\n");
}
writer.close();
MixtureModelProb = new Float[NoBinPoints + 1][3];
float positiveaccu = 0f;
float negativeaccu = 0f;
MixtureModelProb[0][0] = (float) model2.getMaxX() + Float.MIN_VALUE;
MixtureModelProb[0][1] = 1f;
MixtureModelProb[0][2] = 1f;
for (int i = 1; i < NoBinPoints + 1; i++) {
double positiveNumber = correct_kde_y[NoBinPoints - i];
double negativeNumber = decoy_kde_y[NoBinPoints - i];
MixtureModelProb[i][0] = (float) model_kde_x[NoBinPoints - i];
positiveaccu += positiveNumber;
negativeaccu += negativeNumber;
MixtureModelProb[i][2] = 0.999999f * (float) (positiveNumber / (negativeNumber + positiveNumber));
MixtureModelProb[i][1] = 0.999999f * (float) (positiveaccu / (negativeaccu + positiveaccu));
}
XYSeriesCollection dataset = new XYSeriesCollection();
dataset.addSeries(model1);
dataset.addSeries(model2);
dataset.addSeries(model3);
HistogramDataset histogramDataset = new HistogramDataset();
histogramDataset.setType(HistogramType.SCALE_AREA_TO_1);
histogramDataset.addSeries("ID hits", IDObs, 100);
histogramDataset.addSeries("Decoy hits", DecoyObs, 100);
//histogramDataset.addSeries("Model hits", ModelObs, 100);
JFreeChart chart = ChartFactory.createHistogram(FilenameUtils.getBaseName(pngfile), "Score", "Hits", histogramDataset, PlotOrientation.VERTICAL, true, false, false);
XYPlot plot = chart.getXYPlot();
NumberAxis domain = (NumberAxis) plot.getDomainAxis();
domain.setRange(min, max);
plot.setBackgroundPaint(Color.white);
plot.setDomainGridlinePaint(Color.white);
plot.setRangeGridlinePaint(Color.white);
plot.setForegroundAlpha(0.8f);
chart.setBackgroundPaint(Color.white);
XYLineAndShapeRenderer render = new XYLineAndShapeRenderer();
plot.setDataset(1, dataset);
plot.setRenderer(1, render);
plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
try {
ChartUtilities.saveChartAsPNG(new File(pngfile), chart, 1000, 600);
} catch (IOException e) {
}
}
示例6: displayStochi
import org.jfree.data.statistics.HistogramDataset; //导入方法依赖的package包/类
private void displayStochi(final double[] result) {
final HistogramDataset dataset = new HistogramDataset();
dataset.setType(HistogramType.RELATIVE_FREQUENCY);
dataset.addSeries("Unternehmenswert", result, 100);
chart.getXYPlot().setDataset(dataset);
}
示例7: generateDiagram
import org.jfree.data.statistics.HistogramDataset; //导入方法依赖的package包/类
private static void generateDiagram(double[] results2, int bins) {
double[] buffer = new double[results2.length];
for (int i = 0; i < results2.length; i++)
buffer[i] = results2[i];
// The histogram takes an array
HistogramDataset histo = new HistogramDataset();
histo.addSeries("Relative Occurence of Duration", buffer, bins);
histo.setType(HistogramType.RELATIVE_FREQUENCY);
//histo.setType(HistogramType.SCALE_AREA_TO_1);
JFrame aFrame = new JFrame("Time analysis");
//ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
JFreeChart chart = ChartFactory.createHistogram("Distribution of simulated workflow duration",
"Duration of Workflow execution in ms", "Relative occurence", histo, PlotOrientation.VERTICAL, true, true, false);
// to save as JPG
XYPlot plot = (XYPlot) chart.getPlot();
XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer();
renderer.setDrawBarOutline(false);
renderer.setSeriesOutlinePaint(0, Color.red);
//plot.getRangeAxis().setRange(0, 0.2);
//plot.getDomainAxis().setRange(0, 30);
plot.getRangeAxis().setTickLabelFont(new Font("Arial", 0, 30));
plot.getDomainAxis().setTickLabelFont(new Font("Arial", 0, 30));
plot.getRangeAxis().setLabelFont(new Font("Arial", 1, 28));
plot.getDomainAxis().setLabelFont(new Font("Arial", 1, 28));
//plot.getLegendItems().get(0).set(new Font("Arial", 1, 26));
//plot.getLegendItems().get(1).setLabelFont(new Font("Arial", 1, 24));
LegendTitle legend = chart.getLegend();
Font nwfont = new Font("Arial", 0, 26);
legend.setItemFont(nwfont);
//chart.setLegend(legend);
ChartPanel panel = new ChartPanel(chart);
panel.setPreferredSize(new java.awt.Dimension(900, 600));
aFrame.setContentPane(panel);
aFrame.setPreferredSize(new java.awt.Dimension(900, 600));
aFrame.setSize(new Dimension(900, 600));
aFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
aFrame.setVisible(true);
}
示例8: generateDiagram
import org.jfree.data.statistics.HistogramDataset; //导入方法依赖的package包/类
private static void generateDiagram(long[] results2, int bins) {
double[] buffer = new double[results2.length];
for (int i = 0; i < results2.length; i++)
buffer[i] = results2[i];
// The histogram takes an array
HistogramDataset histo = new HistogramDataset();
histo.addSeries("Relative Occurence of Duration", buffer, bins);
//histo.setType(HistogramType.RELATIVE_FREQUENCY);
histo.setType(HistogramType.SCALE_AREA_TO_1);
JFrame aFrame = new JFrame("Time analysis");
//ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
JFreeChart chart = ChartFactory.createHistogram("Distribution of simulated workflow duration",
"Duration of Workflow execution in ms", "Relative occurence", histo, PlotOrientation.VERTICAL, true, true, false);
// to save as JPG
XYPlot plot = (XYPlot) chart.getPlot();
XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer();
renderer.setDrawBarOutline(false);
renderer.setSeriesOutlinePaint(0, Color.red);
//plot.getRangeAxis().setRange(0, 0.2);
//plot.getDomainAxis().setRange(0, 30);
plot.getRangeAxis().setTickLabelFont(new Font("Arial", 0, 30));
plot.getDomainAxis().setTickLabelFont(new Font("Arial", 0, 30));
plot.getRangeAxis().setLabelFont(new Font("Arial", 1, 28));
plot.getDomainAxis().setLabelFont(new Font("Arial", 1, 28));
//plot.getLegendItems().get(0).set(new Font("Arial", 1, 26));
//plot.getLegendItems().get(1).setLabelFont(new Font("Arial", 1, 24));
LegendTitle legend = chart.getLegend();
Font nwfont = new Font("Arial", 0, 26);
legend.setItemFont(nwfont);
//chart.setLegend(legend);
ChartPanel panel = new ChartPanel(chart);
panel.setPreferredSize(new java.awt.Dimension(800, 600));
aFrame.setContentPane(panel);
aFrame.setPreferredSize(new java.awt.Dimension(800, 600));
aFrame.setSize(new Dimension(800, 600));
aFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
aFrame.setVisible(true);
}