List of usage examples for org.jfree.chart.plot XYPlot getRangeAxis
public ValueAxis getRangeAxis()
From source file:org.agmip.ui.afsirs.frames.GraphOutput.java
public void addEvaporationAndTranspiration() { XYSeries etSeries = new XYSeries("ET"); double[][] ET = utils.getET(); for (int i = 0; i < 10/*ET.length*/; i++) { for (int j = 0; j < 10/*ET[0].length*/; j++) { etSeries.add(i * ET[0].length + j, ET[i][j]); }/*from w w w . j a v a 2 s . c o m*/ } XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(etSeries); JFreeChart chart = ChartFactory.createXYLineChart("Evaporation Transpiration", "Days", "Inches", dataset/*, PlotOrientation.VERTICAL, true, true, false*/); chart.setBackgroundPaint(Color.white); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.GRAY); plot.setDomainGridlinePaint(Color.WHITE); plot.setRangeGridlinePaint(Color.white); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, false); renderer.setSeriesShapesVisible(1, false); plot.setRenderer(renderer); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); ChartPanel panel = new ChartPanel(chart); jTabbedPane1.addTab("Evaporation Transpiration", panel); }
From source file:com.cs572.assignments.Project2.view.LineChartPanel.java
/** * Creates a chart.//from w w w . ja va 2 s. c o m * * @param dataset the data for the chart. * * @return a chart. */ private JFreeChart createChart(final XYDataset dataset) { // create the chart... final JFreeChart chart = ChartFactory.createXYLineChart("Expression Tree", // chart title "DataPoints", // x axis label "Output", // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); // final StandardLegend legend = (StandardLegend) chart.getLegend(); // legend.setDisplaySeriesShapes(true); // get a reference to the plot for further customisation... final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, true); renderer.setSeriesLinesVisible(1, true); renderer.setSeriesShapesVisible(0, false); renderer.setSeriesShapesVisible(1, false); plot.setRenderer(renderer); // change the auto tick unit selection to integer units only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:fr.amap.lidar.amapvox.chart.VoxelsToChart.java
public JFreeChart[] getVegetationProfileCharts(LayerReference reference, float maxPAD) { boolean inverseRangeAxis; inverseRangeAxis = !(reference == LayerReference.FROM_ABOVE_GROUND); int quadratNumber = getQuadratNumber(split, length); JFreeChart[] charts = new JFreeChart[quadratNumber]; for (int i = 0; i < quadratNumber; i++) { XYSeriesCollection dataset = new XYSeriesCollection(); for (VoxelFileChart voxelFile : voxelFiles) { int[] indices = getIndiceRange(voxelFile, i); XYSeries serie = createVegetationProfileSerie(voxelFile.reader, voxelFile.label, indices[0], indices[1], reference, maxPAD); dataset.addSeries(serie);/*w ww . java 2 s .co m*/ } List<XYSeries> series = dataset.getSeries(); double correlationValue = Double.NaN; if (series.size() == 2) { XYSeries firstSerie = series.get(0); XYSeries secondSerie = series.get(1); Map<Double, Double[]> valuesMap = new HashMap<>(); for (int j = 0; j < firstSerie.getItemCount(); j++) { Double[] value = new Double[] { firstSerie.getDataItem(j).getXValue(), Double.NaN }; valuesMap.put(firstSerie.getDataItem(j).getYValue(), value); } for (int j = 0; j < secondSerie.getItemCount(); j++) { Double[] value = valuesMap.get(Double.valueOf(secondSerie.getDataItem(j).getYValue())); if (value == null) { valuesMap.put(secondSerie.getDataItem(j).getYValue(), new Double[] { Double.NaN, secondSerie.getDataItem(j).getXValue() }); } else if (Double.isNaN(value[1])) { value[1] = secondSerie.getDataItem(j).getXValue(); valuesMap.put(secondSerie.getDataItem(j).getYValue(), value); } } List<Double> firstList = new ArrayList<>(); List<Double> secondList = new ArrayList<>(); Iterator<Map.Entry<Double, Double[]>> iterator = valuesMap.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry<Double, Double[]> next = iterator.next(); Double[] value = next.getValue(); if (!Double.isNaN(value[0]) && !Double.isNaN(value[1])) { firstList.add(value[0]); secondList.add(value[1]); } } double[] firstArray = new double[firstList.size()]; double[] secondArray = new double[secondList.size()]; for (int j = 0; j < firstList.size(); j++) { firstArray[j] = firstList.get(j); secondArray[j] = secondList.get(j); } PearsonsCorrelation correlation = new PearsonsCorrelation(); correlationValue = correlation.correlation(firstArray, secondArray); } charts[i] = createChart("Vegetation profile" + " - quadrat " + (i + 1), dataset, "PAD", reference.getLabel()); if (!Double.isNaN(correlationValue)) { charts[i].addSubtitle( new TextTitle("R2 = " + (Math.round(Math.pow(correlationValue, 2) * 100)) / 100.0)); } ((XYPlot) charts[i].getPlot()).getRangeAxis().setInverted(inverseRangeAxis); } //set quadrats ranges double minX = 0; double maxX = 0; double minY = 0; double maxY = 0; int id = 0; for (JFreeChart chart : charts) { XYPlot plot = (XYPlot) chart.getPlot(); Range rangeOfRangeAxis = plot.getDataRange(plot.getRangeAxis()); Range rangeOfDomainAxis = plot.getDataRange(plot.getDomainAxis()); double currentMinY = rangeOfRangeAxis.getLowerBound(); double currentMaxY = rangeOfRangeAxis.getUpperBound(); double currentMinX = rangeOfDomainAxis.getLowerBound(); double currentMaxX = rangeOfDomainAxis.getUpperBound(); if (id == 0) { minX = currentMinX; maxX = currentMaxX; minY = currentMinY; maxY = currentMaxY; } else { if (currentMinX < minX) { minX = currentMinX; } if (currentMaxX > maxX) { maxX = currentMaxX; } if (currentMinY < minY) { minY = currentMinY; } if (currentMaxY > maxY) { maxY = currentMaxY; } } id++; } for (JFreeChart chart : charts) { XYPlot plot = (XYPlot) chart.getPlot(); plot.getDomainAxis().setRange(minX, maxX); plot.getRangeAxis().setRange(minY, maxY); } return charts; }
From source file:pharoslabut.logger.CompassLoggerGUI.java
/** * Creates a chart./* ww w .j av a 2 s.c o m*/ * * @param dataset the data for the chart. * * @return a chart. */ private JFreeChart createChart(final XYDataset dataset) { // create the chart... final JFreeChart chart = ChartFactory.createXYLineChart("Proteus Robot Compass Measurements", // chart title "Time (s)", // x axis label "Angle (radians)", // y axis label dataset, // data PlotOrientation.VERTICAL, false, // include legend true, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); // final StandardLegend legend = (StandardLegend) chart.getLegend(); // legend.setDisplaySeriesShapes(true); // get a reference to the plot for further customization... final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, false); renderer.setSeriesShapesVisible(1, false); plot.setRenderer(renderer); final NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setRange(new Range(0, 140)); final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); // change the auto tick unit selection to integer units only... // rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setRange(new Range(-Math.PI, Math.PI)); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:org.agmip.ui.afsirs.frames.GraphOutput.java
public void addWeather() { int nyr = utils.getNYR(); XYSeries etSeries = new XYSeries("ET"); double[][] ET = utils.getET(); for (int i = 0; i < 10/*ET.length*/; i++) { for (int j = 0; j < 10/*ET[0].length*/; j++) { etSeries.add(i * ET[0].length + j, ET[i][j]); }//from ww w. ja va2 s . co m } XYSeries rainSeries = new XYSeries("RAIN"); double[][] RAIN = utils.getRain(); for (int i = 0; i < 10/*RAIN.length*/; i++) { for (int j = 0; j < 10/*RAIN[0].length*/; j++) { rainSeries.add(i * RAIN[0].length + j, RAIN[i][j]); } } XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(etSeries); dataset.addSeries(rainSeries); JFreeChart chart = ChartFactory.createXYLineChart("Weather Data", "Days", "Inches", dataset/*, PlotOrientation.VERTICAL, true, true, false*/); chart.setBackgroundPaint(Color.white); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.GRAY); plot.setDomainGridlinePaint(Color.WHITE); plot.setRangeGridlinePaint(Color.white); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, false); renderer.setSeriesShapesVisible(1, false); plot.setRenderer(renderer); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); ChartPanel panel = new ChartPanel(chart); jTabbedPane1.addTab("Weather", panel); }
From source file:org.objectweb.proactive.extensions.timitspmd.util.charts.MatrixChart.java
private void buildMainChart(String title, String subTitle, String xAxisLabel, String yAxisLabel, String fileName) {//from w w w. j ava 2 s .c o m final MatrixSeriesCollection dataset = new MatrixSeriesCollection(this.createMatrixDataSet()); final JFreeChart chart = ChartFactory.createBubbleChart(title, xAxisLabel, yAxisLabel, dataset, PlotOrientation.VERTICAL, true, true, false); chart.addSubtitle(new TextTitle(subTitle)); chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.WHITE)); chart.removeLegend(); // Perform customizations starts here ... final XYPlot plot1 = chart.getXYPlot(); plot1.setDomainGridlinesVisible(false); plot1.setRangeGridlinesVisible(false); plot1.setForegroundAlpha(0.5f); plot1.setDomainAxis(new CustomAxis(plot1.getDomainAxis().getLabel())); plot1.setRangeAxis(new CustomAxis(plot1.getRangeAxis().getLabel())); // Custumize the domain axis ( y ) final NumberAxis domainAxis = (NumberAxis) plot1.getDomainAxis(); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); domainAxis.setRange(-1, this.array.length); // Custumize the range axis ( y ) final NumberAxis rangeAxis = (NumberAxis) plot1.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setRange(-1, this.array.length); // Create custom renderer StandardXYItemRenderer ren = new CustomRenderer(false); ren.setSeriesItemLabelPaint(0, Color.BLACK); plot1.setRenderer(ren); this.mainChart = chart; }
From source file:edu.ucla.stat.SOCR.chart.demo.ScatterChartDemo1.java
/** * Creates a chart./* ww w. j a v a 2 s. c o m*/ * * @param dataset the data for the chart. * * @return a chart. */ protected JFreeChart createChart(XYDataset dataset) { // create the chart... JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, // chart title domainLabel, // x axis label rangeLabel, // y axis label dataset, // data PlotOrientation.VERTICAL, !legendPanelOn, // include legend true, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); renderer.setBaseLinesVisible(false); renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator()); // change the auto tick unit selection to integer units only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setAutoRangeIncludesZero(false); rangeAxis.setUpperMargin(0); rangeAxis.setLowerMargin(0); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); domainAxis.setAutoRangeIncludesZero(false); domainAxis.setUpperMargin(0); domainAxis.setLowerMargin(0); // OPTIONAL CUSTOMISATION COMPLETED. setXSummary(dataset); return chart; }
From source file:com.al.cellplugin.LineChart.java
/** * Creates a chart./*from w ww . j a va 2 s . c om*/ * * @param dataset the data for the chart. * * @return a chart. */ private JFreeChart createChart(final XYDataset dataset) { // create the chart... final JFreeChart chart = ChartFactory.createXYLineChart("Line Chart of Product SVD [V]", // chart title "X", // x axis label "Y", // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); // final StandardLegend legend = (StandardLegend) chart.getLegend(); // legend.setDisplaySeriesShapes(true); // get a reference to the plot for further customisation... final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setRangeGridlinesVisible(true); final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, true); renderer.setSeriesShapesVisible(1, false); plot.setRenderer(renderer); // change the auto tick unit selection to integer units only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); //rangeAxis.setTickLabelsVisible(true); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:edu.illinois.ncsa.datawolf.service.ExecutionsResource.java
private JFreeChart createChart(String xVariable, String yVariable, XYDataset dataset) { final JFreeChart chart = ChartFactory.createXYLineChart("Convergence Graph", xVariable, yVariable, dataset, PlotOrientation.VERTICAL, true, true, false); chart.setBackgroundPaint(Color.WHITE); final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.LIGHT_GRAY); plot.setDomainGridlinePaint(Color.WHITE); plot.setRangeGridlinePaint(Color.WHITE); final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return chart; }
From source file:edu.utexas.ece.pharos.proteus3.sensors.CompassChartGUI.java
/** * Creates a chart.//w ww .j a va 2 s. c o m * * @param dataset the data for the chart. * * @return a chart. */ private JFreeChart createChart(final XYDataset dataset) { // create the chart... final JFreeChart chart = ChartFactory.createXYLineChart("Proteus III Compass Measurements", // chart title "Time (s)", // x axis label "Angle (degrees)", // y axis label dataset, // data PlotOrientation.VERTICAL, false, // include legend true, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); // final StandardLegend legend = (StandardLegend) chart.getLegend(); // legend.setDisplaySeriesShapes(true); // get a reference to the plot for further customization... final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, false); renderer.setSeriesShapesVisible(1, false); plot.setRenderer(renderer); final NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setRange(new Range(0, 140)); final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); // change the auto tick unit selection to integer units only... // rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); //rangeAxis.setRange(new Range(-Math.PI, Math.PI)); rangeAxis.setRange(new Range(-180, 180)); return chart; }