HistogramDataset dataset = new HistogramDataset(); dataset.addSeries("series label",arrayOfValues,noOfBins);
HistogramDataset dataSet = new HistogramDataset(); dataSet.setType(HistogramType.FREQUENCY); dataSet.addSeries("Hibernate", Doubles.toArray(values), 1000);
/** * Adds a series to the dataset, using the specified number of bins, * and sends a {@link DatasetChangeEvent} to all registered listeners. * * @param key the series key ({@code null} not permitted). * @param values the values ({@code null} not permitted). * @param bins the number of bins (must be at least 1). */ public void addSeries(Comparable key, double[] values, int bins) { // defer argument checking... double minimum = getMinimum(values); double maximum = getMaximum(values); addSeries(key, values, bins, minimum, maximum); }
/** * Adds a series to the dataset, using the specified number of bins. * * @param key the series key (<code>null</code> not permitted). * @param values the values (<code>null</code> not permitted). * @param bins the number of bins (must be at least 1). */ public void addSeries(Comparable key, double[] values, int bins) { // defer argument checking... double minimum = getMinimum(values); double maximum = getMaximum(values); addSeries(key, values, bins, minimum, maximum); }
dataset.addSeries("Hist",data,200); // Number of bins is 50 String plotTitle = ""; String xAxis = "Frequency";
/** 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; }
private XYPlot createResponseTimesPlot(AggregatedResponses aggregatedResponses) { Samples durations = aggregatedResponses.getDuration(); // Distribution double[] values = new double[durations.getSamples().size()]; for (int i = 0; i < durations.getSamples().size(); i++) { values[i] = durations.getSamples().get(i); } HistogramDataset histogramdataset = new HistogramDataset(); histogramdataset.addSeries("Request Count", values, 40); // Percentiles List<Double> y = new ArrayList<Double>(Q + 1); List<Long> x = new ArrayList<Long>(Q + 1); Quantile quantile = durations.getQuantiles(Q); // Add zero value y.add(0D); x.add(0L); for (int i = 1; i < Q; i++) { y.add(((double) i) / 10); x.add(quantile.getQuantile(i)); } // Add max value y.add(100D); x.add(durations.getMax()); XYPlot plot = ChartUtil.createResponseTimesPlot("Response Times (ms)"); ChartUtil.addDatasetRender(plot, new XYSeriesCollection( createValuesSeries("Percentiles", x, y, 0)), ChartUtil.createLineAndShapeRenderer()); ChartUtil.addDatasetRender(plot, histogramdataset, ChartUtil.createBarRenderer()); plot.mapDatasetToRangeAxis(1, 1); return plot; }
private static JFreeChart createHistogram(List<Double> samples) { double[] data = new double[samples.size()]; for (int i = 0; i < samples.size(); i++) { data[i] = samples.get(i); } // int number = data.length; HistogramDataset dataset = new HistogramDataset(); dataset.setType(HistogramType.RELATIVE_FREQUENCY); dataset.addSeries("Hist", data, 200); String plotTitle = ""; String xAxis = "Value"; String yAxis = "Frequency"; PlotOrientation orientation = PlotOrientation.VERTICAL; boolean show = false; boolean toolTips = false; boolean urls = false; JFreeChart chart = ChartFactory.createHistogram(plotTitle, xAxis, yAxis, dataset, orientation, show, toolTips, urls); chart.setBackgroundPaint(Color.white); return chart; }
histogramdataset.addSeries( label, sampleArray, BINS ); JFreeChart chart = ChartFactory.createHistogram( bundle.getString( "chronos.label.histogram" ), bundle.getString( "chronos.label.histogram.x" ),
dataset.setType(HistogramType.FREQUENCY); dataset.addSeries("Frequencies", values, numberOfBins, 0, numberOfBins * this.session.chartData.getSAXWindowSize());
public void createChart(String pngFileName){ HistogramDataset dataset = new HistogramDataset(); dataset.setType(HistogramType.FREQUENCY); double [] values = getValuesBetween(getMinScore(), getMaxScore()); dataset.addSeries(getTitle(), values,getNumberOfBars(),getMinScore(),getMaxScore()); String plotTitle = getTitle(); String xaxis = "Score"; String yaxis = "Number of interactions"; PlotOrientation orientation = PlotOrientation.VERTICAL; boolean show = false; boolean toolTips = false; boolean urls = false; JFreeChart chart = ChartFactory.createHistogram( plotTitle, xaxis, yaxis, dataset, orientation, show, toolTips, urls); // get a reference to the plot for further customisation... final XYPlot plot = chart.getXYPlot(); plot.getRangeAxis().setAutoRange(true); try { ChartUtilities.saveChartAsPNG(new File(pngFileName), chart, getWidth(), getHeight()); } catch (IOException e) { e.printStackTrace(); } }
public void createRelativeChart(String pngFileName){ HistogramDataset dataset = new HistogramDataset(); dataset.setType(HistogramType.RELATIVE_FREQUENCY); double [] values = getValuesBetween(getMinScore(), getMaxScore()); dataset.addSeries(getTitle(), values,getNumberOfBars(),getMinScore(),getMaxScore()); String plotTitle = getTitle(); String xaxis = "Score"; String yaxis = "% of interactions"; PlotOrientation orientation = PlotOrientation.VERTICAL; boolean show = false; boolean toolTips = false; boolean urls = false; JFreeChart chart = ChartFactory.createHistogram( plotTitle, xaxis, yaxis, dataset, orientation, show, toolTips, urls); // get a reference to the plot for further customisation... final XYPlot plot = chart.getXYPlot(); plot.getRangeAxis().setAutoRange(true); try { ChartUtilities.saveChartAsPNG(new File(pngFileName), chart, getWidth(), getHeight()); } catch (IOException e) { e.printStackTrace(); } }