List of usage examples for org.jfree.chart ChartFactory createHistogram
public static JFreeChart createHistogram(String title, String xAxisLabel, String yAxisLabel, IntervalXYDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls)
From source file:com.signalcollect.sna.gephiconnectors.SignalCollectGephiConnector.java
/** * Creates the Chart of the Degree Distribution according to the calculated * distribution/*from w w w . j a v a 2s . c o m*/ * * @param degreeDistribution * @return a {@link JFreeChart} containing the distribution of degrees in * the graph * @throws IOException */ public JFreeChart createDegreeDistributionChart(Map<Integer, Integer> degreeDistribution) throws IOException { XYSeries dSeries = new XYSeries("number of occurences"); for (Iterator it = degreeDistribution.entrySet().iterator(); it.hasNext();) { Map.Entry d = (Map.Entry) it.next(); Number x = (Number) d.getKey(); Number y = (Number) d.getValue(); dSeries.add(x, y); } XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(dSeries); dataset.setAutoWidth(true); JFreeChart chart = ChartFactory.createHistogram("Degree Distribution", "Degree centrality value", "number of occurences", dataset, PlotOrientation.VERTICAL, true, true, true); XYPlot plot = chart.getXYPlot(); XYBarRenderer renderer0 = new XYBarRenderer(); Font font = new Font("Font", 0, 14); renderer0.setMargin(0.2); renderer0.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator()); renderer0.setBaseItemLabelsVisible(true); renderer0.setBaseItemLabelFont(font); plot.setDataset(0, dataset); plot.setRenderer(0, renderer0); plot.getRendererForDataset(plot.getDataset(0)).setSeriesPaint(0, Color.BLUE); return chart; }
From source file:presenter.MainPresenter.java
@Override public void createHistogram() { HistogramDataset histData = new HistogramDataset(); histData.setType(HistogramType.FREQUENCY); double[] values = this.emissionsequenceModel.getEmissionsAsArray(); histData.addSeries("H1", values, EmissionsequenceModel.EMISSIONCOUNT); JFreeChart chart;//from ww w . jav a2s . co m if (this.model != null) { chart = ChartFactory.createHistogram(this.model.getName(), "EmissionID", "Frequency", histData, PlotOrientation.VERTICAL, false, false, false); } else { chart = ChartFactory.createHistogram("unknown Model", "EmissionID", "Frequency", histData, PlotOrientation.VERTICAL, false, false, false); } new HistogramView(new ChartPanel(chart)); }
From source file:de.mpg.mpi_inf.bioinf.netanalyzer.ui.charts.JFreeChartConn.java
/** * Creates a histogram chart that displays the given long histogram data. * /*from ww w . j a v a 2s .com*/ * @param aHistogram * Complex parameter that stores the data to be visualized. * @param aSettings * Settings group for long histogram. * @return Newly created chart control. */ public static JFreeChart createHistogram(LongHistogram aHistogram, LongHistogramGroup aSettings) { XYSeriesCollection collection = fromLongHistogram(aHistogram); JFreeChart chart = ChartFactory.createHistogram(null, // title convertLabel(aSettings.axes.getDomainAxisLabel()), // label of X axis convertLabel(aSettings.axes.getRangeAxisLabel()), // label of Y axis collection, // dataset PlotOrientation.VERTICAL, // orientation false, // create legend false, // display tooltips false); // generate urls XYPlot plot = chart.getXYPlot(); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); updateGeneral(plot, aSettings.general); updateAxes(chart, aSettings.axes, aSettings.grid); updateBars(plot, aSettings.bars); chart.setBackgroundPaint(null); return chart; }
From source file:agentlogfileanalyzer.histogram.AbstractHistogram.java
/** * Returns a panel containing a histogram. The data displayed in the * histogram is given as parameter. Data not inside the given limits is * discarded./* w w w .j av a 2 s . co m*/ * * @param _histogramData * the data displayed in the histogram * @param _lowerLimit * the lower limit that was entered by the user * @param _upperLimit * the upper limit that was entered by the user * @return a <code>JPanel</code> containing the histogram */ JPanel createHistogram(Vector<Double> _histogramData, double _lowerLimit, double _upperLimit) { // Remove values outside the given limits... Vector<Double> vectorHistogramDataWithinLimits = new Vector<Double>(); for (Iterator<Double> iterator = _histogramData.iterator(); iterator.hasNext();) { double d = ((Double) iterator.next()).doubleValue(); if (valueWithinLimits(d, _lowerLimit, _upperLimit)) { vectorHistogramDataWithinLimits.add(d); } } // Store number of elements shown in histogram... this.numberOfVisibleClassifiers = vectorHistogramDataWithinLimits.size(); // Convert vector to array... double[] arrayHistogramDataWithinLimits = new double[vectorHistogramDataWithinLimits.size()]; for (int i = 0; i < vectorHistogramDataWithinLimits.size(); i++) { double d = vectorHistogramDataWithinLimits.get(i).doubleValue(); arrayHistogramDataWithinLimits[i] = d; } if (arrayHistogramDataWithinLimits.length > 0) { // Create // histogram... HistogramDataset data = new HistogramDataset(); data.addSeries("Suchwert", // key arrayHistogramDataWithinLimits, // data Math.max(100, arrayHistogramDataWithinLimits.length) // #bins ); JFreeChart chart = ChartFactory.createHistogram(description, // title description, // x axis label "frequency", // y axis label data, // data PlotOrientation.VERTICAL, // orientation false, // legend true, // tooltips false // URL ); return new ChartPanel(chart); } else { return createErrorPanel("No data available (within the given limits)."); } }
From source file:visualizer.projection.distance.view.DistanceHistogram.java
private JFreeChart createChart(IntervalXYDataset intervalxydataset) { JFreeChart chart = ChartFactory.createHistogram("Distance Histogram", "Distances Values", "Occurences", intervalxydataset, PlotOrientation.VERTICAL, true, true, false); // JFreeChart chart = ChartFactory.createHistogram("Histograma das Distncias", // "Valores", "Ocorrncias", intervalxydataset, // PlotOrientation.VERTICAL, true, true, false); chart.setBackgroundPaint(Color.WHITE); XYPlot xyplot = (XYPlot) chart.getPlot(); NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis(); numberaxis.setAutoRangeIncludesZero(false); xyplot.setDomainGridlinePaint(Color.BLACK); xyplot.setRangeGridlinePaint(Color.BLACK); xyplot.setOutlinePaint(Color.BLACK); xyplot.setOutlineStroke(new BasicStroke(1.0f)); xyplot.setBackgroundPaint(Color.white); xyplot.setDomainCrosshairVisible(true); xyplot.setRangeCrosshairVisible(true); XYBarRenderer xybarrenderer = (XYBarRenderer) xyplot.getRenderer(); xybarrenderer.setDrawBarOutline(false); return chart; }
From source file:net.bioclipse.chart.ChartUtils.java
/** * Displays histogram of the values in ChartView * //from w w w . j av a 2s . com * @param values Data values * @param bins Number of bins to use * @param xLabel X axis label * @param yLabel Y axis label * @param title Histogram title */ public static void histogram(double[] values, int bins, String xLabel, String yLabel, String title, IEditorPart dataSource) { setupData(values, null, xLabel, yLabel, title); HistogramDataset histogramData = new HistogramDataset(); histogramData.addSeries(1, values, bins); chart = ChartFactory.createHistogram(title, xLabel, yLabel, histogramData, PlotOrientation.VERTICAL, false, false, false); ChartDescriptor descriptor = new ChartDescriptor(dataSource, null, ChartConstants.HISTOGRAM, xLabel, yLabel); chartManager.put(chart, descriptor); view.display(chart); ChartUtils.currentPlotType = ChartConstants.HISTOGRAM; }
From source file:fr.ens.transcriptome.corsen.gui.qt.ResultGraphs.java
public QImage createDistanceDistributionImage(final double[] data, final int classes, final String unit) { if (data == null || data.length < 2) return null; HistogramDataset histogramdataset = new HistogramDataset(); histogramdataset.addSeries("Min distances", data, classes, getMin(data), getMax(data)); // createHistoDataSet(results.getMaxDistances(), "Max distances", // histogramdataset); JFreeChart chart = ChartFactory.createHistogram("Distribution of minimal distances", // title "Distance" + unitLegend(unit), // domain axis label "Cell number", // range axis label histogramdataset, // data PlotOrientation.VERTICAL, // orientation false, // include legend true, // tooltips? false // URLs? );//w ww. j av a 2 s. c o m addTransparency(chart); final BufferedImage image = chart.createBufferedImage(this.width, this.height, BufferedImage.TYPE_INT_ARGB, null); return new QImage(toByte(image.getData().getDataBuffer()), this.width, this.height, QImage.Format.Format_ARGB32); }
From source file:ch.zhaw.ias.dito.ui.AnalysisPanel.java
private JFreeChart createHistogramChart(String title, Matrix distanceMatrix) { int NUM_OF_BINS = 50; SimpleHistogramDataset dataset = new SimpleHistogramDataset(""); dataset.setAdjustForBinSize(false);//from ww w . j a v a2s .c o m double min = distanceMatrix.extremum(false); double max = distanceMatrix.extremum(true); double spacing = (max - min) / NUM_OF_BINS; double currentBound = min; for (int i = 0; i < NUM_OF_BINS - 1; i++) { dataset.addBin(new SimpleHistogramBin(currentBound, (currentBound + spacing), true, false)); currentBound += spacing; } //ensure that the maximum is included and not lost because of numerical problems dataset.addBin(new SimpleHistogramBin(currentBound, max, true, true)); for (int i = 0; i < distanceMatrix.getColCount(); i++) { DVector v = distanceMatrix.col(i); dataset.addObservations(v.getValues()); } return ChartFactory.createHistogram(title, Translation.INSTANCE.get("misc.graphic.distance"), Translation.INSTANCE.get("misc.graphic.frequency"), dataset, PlotOrientation.VERTICAL, false, true, false); }
From source file:com.signalcollect.sna.gephiconnectors.SignalCollectGephiConnector.java
/** * Creates the Chart of the Clustering Distribution according to the * calculated distribution//w w w . java 2s. co m * * @param clusterDistribution * @return a {@link JFreeChart} containing the distribution of local cluster * coefficients in the graph * @throws IOException */ public JFreeChart createClusterDistributionChart(Map<Double, Integer> clusterDistribution) throws IOException { XYSeries dSeries = new XYSeries("number of occurences"); for (Iterator it = clusterDistribution.entrySet().iterator(); it.hasNext();) { Map.Entry d = (Map.Entry) it.next(); Number x = (Number) d.getKey(); Number y = (Number) d.getValue(); dSeries.add(x, y); } XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(dSeries); dataset.setAutoWidth(true); JFreeChart chart = ChartFactory.createHistogram("Local Cluster Coefficient Distribution", "Local Cluster Coefficient value", "number of occurences", dataset, PlotOrientation.VERTICAL, true, true, true); XYPlot plot = chart.getXYPlot(); XYBarRenderer renderer0 = new XYBarRenderer(); Font font = new Font("Font", 0, 14); renderer0.setMargin(0.2); renderer0.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator()); renderer0.setBaseItemLabelsVisible(true); renderer0.setBaseItemLabelFont(font); plot.setDataset(0, dataset); plot.setRenderer(0, renderer0); plot.getRendererForDataset(plot.getDataset(0)).setSeriesPaint(0, Color.BLUE); return chart; }
From source file:org.simbrain.plot.histogram.HistogramPanel.java
/** * Create the histogram panel based on the data. *///from ww w.ja v a 2 s . c o m public void createHistogram() { try { if (this.getModel().getData() != null) { mainChart = ChartFactory.createHistogram(title, xAxisName, yAxisName, model.getDataSet(), PlotOrientation.VERTICAL, true, true, false); mainChart.setBackgroundPaint(UIManager.getColor("this.Background")); XYPlot plot = (XYPlot) mainChart.getPlot(); plot.setForegroundAlpha(0.75F); // Sets y-axis ticks to integers. NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); renderer.setShadowVisible(false); Iterator<ColoredDataSeries> series = model.getSeriesData().iterator(); for (int i = 0; i < model.getData().size(); i++) { if (i < colorPallet.length) { ColoredDataSeries s = series.next(); Color c = s.color; if (c == null) { c = assignColor(); s.color = c; } renderer.setSeriesPaint(i, c, true); } } } else { mainChart = ChartFactory.createHistogram(title, xAxisName, yAxisName, model.getDataSet(), PlotOrientation.VERTICAL, true, true, false); mainChart.setBackgroundPaint(UIManager.getColor("this.Background")); } } catch (IllegalArgumentException iaEx) { iaEx.printStackTrace(); JOptionPane.showMessageDialog(null, iaEx.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } catch (IllegalStateException isEx) { isEx.printStackTrace(); JOptionPane.showMessageDialog(null, isEx.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } mainPanel = new ChartPanel(mainChart); }