List of usage examples for org.jfree.chart ChartFactory createXYLineChart
public static JFreeChart createXYLineChart(String title, String xAxisLabel, String yAxisLabel, XYDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls)
From source file:eu.choreos.chart.XYChart.java
private JFreeChart createChart(XYDataset dataset, String chartTitle) { // create the chart... JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, // chart title "Execution size", // domain axis label "Range", // range axis label dataset, // initial series PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips? false // URLs? );//from w w w . j a v a2 s . c o m // set chart background chart.setBackgroundPaint(Color.white); // set a few custom plot features XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(new Color(0xffffe0)); plot.setDomainGridlinesVisible(true); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); // set the plot's axes to display integers TickUnitSource ticks = NumberAxis.createIntegerTickUnits(); NumberAxis domain = (NumberAxis) plot.getDomainAxis(); domain.setStandardTickUnits(ticks); domain.resizeRange(1.1); domain.setLowerBound(0.5); NumberAxis range = (NumberAxis) plot.getRangeAxis(); range.setStandardTickUnits(ticks); range.setUpperBound(range.getUpperBound() * 1.1); // render shapes and lines XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, true); plot.setRenderer(renderer); renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); // set the renderer's stroke Stroke stroke = new BasicStroke(3f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL); renderer.setBaseOutlineStroke(stroke); // label the points NumberFormat format = NumberFormat.getNumberInstance(); format.setMaximumFractionDigits(2); XYItemLabelGenerator generator = new StandardXYItemLabelGenerator( StandardXYItemLabelGenerator.DEFAULT_ITEM_LABEL_FORMAT, format, format); renderer.setBaseItemLabelGenerator(generator); renderer.setBaseItemLabelsVisible(true); return chart; }
From source file:sim.app.sugarscape.Charts.java
JFreeChart createEvolution() { JFreeChart chart = ChartFactory.createXYLineChart("Evolution of Mean Agent Vision and Metabolism", "Time", "Level", model.evolution_vision_coll, PlotOrientation.VERTICAL, true, true, false); model.evolution_chart = chart;/* ww w .j a va2 s . c om*/ NumberAxis rangeAxis1 = new NumberAxis("Time"); rangeAxis1.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); org.jfree.chart.axis.NumberAxis domainAxis = new NumberAxis("Bins"); XYPlot plot = chart.getXYPlot(); ValueAxis xAxis = plot.getDomainAxis(); XYItemRenderer renderer = plot.getRenderer(); renderer.setSeriesPaint(0, Color.BLACK); plot.setDataset(1, model.evolution_metabolism_coll); renderer.setSeriesPaint(1, Color.BLUE); return chart; }
From source file:net.bioclipse.chart.ChartUtils.java
/** * Displays data in a line plot//from w ww .ja va2 s . com * * @param xValues x values of points * @param yValues y values of points * @param xLabel X axis label * @param yLabel Y axis label * @param title Chart title * @param analysisMatrixEditor * @param indices */ public static void linePlot(double[] xValues, double[] yValues, String xLabel, String yLabel, String title, int[] indices, IEditorPart dataSource) { setupData(xValues, yValues, xLabel, yLabel, title); PcmLineChartDataset dataset = new PcmLineChartDataset(values, nameOfObs, xLabel, yLabel, "", title, null); chart = ChartFactory.createXYLineChart(title, xLabel, yLabel, dataset, PlotOrientation.VERTICAL, true, true, false); ChartDescriptor cd = new ChartDescriptor(dataSource, indices, ChartConstants.LINE_PLOT, xLabel, yLabel); chartManager.put(chart, cd); view.display(chart); }
From source file:edu.ucla.stat.SOCR.chart.demo.XYStepRendererDemo1.java
protected JFreeChart createLegend(XYDataset dataset) { JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, // chart title domainLabel, // domain axis label rangeLabel, // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips false // url );//w w w . j a va2 s .co m // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); XYStepRenderer renderer = new XYStepRenderer(); renderer.setBaseStroke(new BasicStroke(2.0f)); renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); renderer.setDefaultEntityRadius(6); renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator()); plot.setRenderer(renderer); return chart; }
From source file:playground.artemc.socialCost.MeanTravelTimeWriter.java
/** * @return a graphic showing the number of agents in the evacuated area *///from w w w .j a va 2s . c om private JFreeChart getGraphic(String modeName, double data[]) { final XYSeriesCollection xyData = new XYSeriesCollection(); final XYSeries dataSerie = new XYSeries("mean trip travel time", false, true); for (int i = 0; i < data.length; i++) { dataSerie.add(i, data[i]); } xyData.addSeries(dataSerie); // final JFreeChart chart = ChartFactory.createXYStepChart( final JFreeChart chart = ChartFactory.createXYLineChart("mean travel time, " + modeName, "iteration", "travel time", xyData, PlotOrientation.VERTICAL, true, // legend false, // tooltips false // urls ); XYPlot plot = chart.getXYPlot(); final CategoryAxis axis1 = new CategoryAxis("hour"); axis1.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 7)); plot.setDomainAxis(new NumberAxis("time")); return chart; }
From source file:mainGUI.TrainingJFrame.java
private void initLineChartPanel() { series = new XYSeries("MSE"); seriesCollection = new XYSeriesCollection(series); chart = ChartFactory.createXYLineChart("Training", "Epoch Number", "MSE", seriesCollection, PlotOrientation.VERTICAL, true, true, true); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true);/*from w ww. ja va 2 s. c o m*/ renderer.setBaseStroke(new BasicStroke(3)); XYPlot plot = (XYPlot) chart.getPlot(); plot.setRenderer(renderer); chartPanel = new ChartPanel(chart); chartPanel.setSize(chartContainerPanel.getWidth(), chartContainerPanel.getHeight()); chartContainerPanel.add(chartPanel); }
From source file:org.encog.workbench.dialogs.activation.EquationPanel.java
/** * Creates a line chart using the data from the supplied dataset. * * @param dataset the dataset.//from w ww. ja va 2s . c om * * @return The chart. */ public static JFreeChart createChart(XYDataset dataset, ActivationFunction activation, boolean normal) { String title; if (normal) { title = activation.getClass().getSimpleName(); } else { if (activation.hasDerivative()) { title = "Derv of " + activation.getClass().getSimpleName(); } else { title = "NO Derv of " + activation.getClass().getSimpleName(); } } JFreeChart chart = ChartFactory.createXYLineChart(title, "input (x)", "output (y)", dataset, PlotOrientation.VERTICAL, true, true, false); XYPlot plot = (XYPlot) chart.getPlot(); if (normal) { plot.setDomainZeroBaselineVisible(true); plot.setRangeZeroBaselineVisible(true); plot.setDomainPannable(true); plot.setRangePannable(true); ValueAxis xAxis = plot.getDomainAxis(); xAxis.setLowerMargin(0.0); xAxis.setUpperMargin(0.0); XYLineAndShapeRenderer r = (XYLineAndShapeRenderer) plot.getRenderer(); r.setDrawSeriesLineAsPath(true); r.setSeriesStroke(0, new BasicStroke(1.5f)); r.setSeriesStroke(1, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 6.0f, 4.0f }, 0.0f)); r.setSeriesStroke(2, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 6.0f, 4.0f, 3.0f, 3.0f }, 0.0f)); r.setSeriesStroke(3, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 4.0f, 4.0f }, 0.0f)); } return chart; }
From source file:eu.cassandra.training.utils.ChartUtils.java
/** * This function is used for the visualization of a Comparative Response Model * Histogram.//from ww w . j a v a 2 s . c om * * @param title * The title of the chart. * @param x * The unit on the X axis of the chart. * @param y * The unit on the Y axis of the chart. * @param dataBefore * The array of values before the response. * @param dataAfter * The array of values after the response. * @return a chart panel with the graphical representation. */ public static ChartPanel createResponseHistogram(String title, String x, String y, double[] dataBefore, double[] dataAfter) { XYSeries series1 = new XYSeries("Basic Pricing Scheme"); for (int i = 0; i < dataBefore.length; i++) { series1.add(i, dataBefore[i]); } XYSeries series2 = new XYSeries("New Pricing Scheme"); for (int i = 0; i < dataAfter.length; i++) { series2.add(i, dataAfter[i]); } XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(series1); dataset.addSeries(series2); PlotOrientation orientation = PlotOrientation.VERTICAL; boolean show = true; boolean toolTips = false; boolean urls = false; JFreeChart chart = ChartFactory.createXYLineChart(title, x, y, dataset, orientation, show, toolTips, urls); XYPlot xyplot = (XYPlot) chart.getPlot(); xyplot.setDomainPannable(true); xyplot.setRangePannable(true); xyplot.setForegroundAlpha(0.85F); NumberAxis domainAxis = (NumberAxis) xyplot.getDomainAxis(); // domainAxis.setRange(0.0, 1440.0); domainAxis.setTickUnit(new NumberTickUnit(10)); NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis(); numberaxis.setTickUnit(new NumberTickUnit(0.1)); return new ChartPanel(chart); }
From source file:com.opendoorlogistics.components.linegraph.LineGraphPanel.java
@Override protected JFreeChart createChart(ODLTableReadOnly table, int[] rowFilter) { // split by key Map<String, List<XY>> lines = api.stringConventions().createStandardisedMap(); if (rowFilter != null) { for (int row : rowFilter) { readLine(table, row, lines); }//from w w w . ja v a 2 s.c o m } else { int n = table.getRowCount(); for (int row = 0; row < n; row++) { readLine(table, row, lines); } } XYSeriesCollection dataset = new XYSeriesCollection(); for (Map.Entry<String, List<XY>> line : lines.entrySet()) { XYSeries s = new XYSeries(line.getKey()); for (XY xy : line.getValue()) { s.add(xy.X, xy.Y); } dataset.addSeries(s); } JFreeChart chart = ChartFactory.createXYLineChart( api.stringConventions().isEmptyString(config.getTitle()) ? null : config.getTitle(), // chart title config.getXLabel(), // x axis label config.getYLabel(), // y axis label dataset, // data PlotOrientation.VERTICAL, lines.size() > 0, // include legend true, // tooltips false // urls ); // make lines thicker for (int i = 0; i < lines.size(); i++) { ((XYPlot) chart.getPlot()).getRenderer().setSeriesStroke(i, new BasicStroke(2)); } // set the background color for the chart... chart.setBackgroundPaint(Color.WHITE); return chart; }
From source file:FreeMemoryViewer.java
private JFreeChart createChart(XYDataset dataset, String title) { JFreeChart chart = ChartFactory.createXYLineChart(title, "X", "Y", dataset, PlotOrientation.VERTICAL, true, true, false);//from w ww .j a va 2 s . com XYPlot plot = chart.getXYPlot(); XYSplineRenderer renderer = new XYSplineRenderer(); // Curve plot.setRenderer(renderer); return chart; }