List of usage examples for org.jfree.chart.plot XYPlot setRangeGridlinePaint
public void setRangeGridlinePaint(Paint paint)
From source file:org.ietr.preesm.mapper.ui.stats.PerformancePlotter.java
/** * Creates a chart in order to plot the speed-ups. * /*w w w . ja v a 2s. c om*/ * @return A chart. */ private JFreeChart createChart(String title) { // Creating display domain NumberAxis horizontalAxis = new NumberAxis("Number of operators"); final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(horizontalAxis); // Creating the best speedups subplot this.speedups = new DefaultXYDataset(); final NumberAxis xAxis = new NumberAxis("speedups"); xAxis.setAutoRangeIncludesZero(false); XYSplineRenderer renderer = new XYSplineRenderer(); final XYPlot subplot = new XYPlot(this.speedups, null, xAxis, renderer); subplot.setBackgroundPaint(Color.white); subplot.setDomainGridlinePaint(Color.lightGray); subplot.setRangeGridlinePaint(Color.lightGray); plot.add(subplot); plot.setForegroundAlpha(0.5f); final JFreeChart chart = new JFreeChart(title, plot); chart.setBorderPaint(Color.white); chart.setBorderVisible(true); chart.setBackgroundPaint(Color.white); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); final ValueAxis axis = plot.getDomainAxis(); axis.setAutoRange(true); return chart; }
From source file:edu.ucla.stat.SOCR.chart.ChartGenerator.java
private JFreeChart createLineChart(String title, String xLabel, String yLabel, XYDataset dataset, String other) {/*from w ww . j av a2 s . c om*/ // create the chart... JFreeChart chart = ChartFactory.createXYLineChart(title, // chart title xLabel, // domain axis label yLabel, // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation false, // include legend true, // tooltips false // urls ); chart.setBackgroundPaint(Color.white); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setRangeGridlinePaint(Color.white); plot.setDomainGridlinePaint(Color.white); //plot.setNoDataMessage("No data available"); // customise the range axis... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); //rangeAxis.setAutoRange(false); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); // domainAxis.setAutoRange(false); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // customise the renderer... XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setBaseShapesVisible(true); renderer.setBaseLinesVisible(false); renderer.setDrawOutlines(true); renderer.setBaseShapesFilled(true); renderer.setUseFillPaint(true); //renderer.setFillPaint(Color.white); if (other.toLowerCase().indexOf("noshape") != -1) { renderer.setBaseShapesVisible(false); renderer.setBaseLinesVisible(true); } if (other.toLowerCase().indexOf("excludeszero") != -1) { rangeAxis.setAutoRangeIncludesZero(false); domainAxis.setAutoRangeIncludesZero(false); } return chart; }
From source file:web.diva.server.unused.PCAGenerator.java
public PCAImageResult generateChart(String path, PCAResults pcaResults, int[] subSelectionData, int[] selection, boolean zoom, boolean selectAll, String imgName, double w, double h, DivaDataset divaDataset) { XYDataset dataset = this.createDataset(pcaResults.getPoints(), subSelectionData, selection, zoom, divaDataset);/*from ww w.j a va2s . c o m*/ final JFreeChart chart = ChartFactory.createScatterPlot("", // chart title "Principal Component" + (pcaResults.getPcai() + 1), // x axis label "Principal Component " + (pcaResults.getPcaii() + 1), // y axis label dataset, // data PlotOrientation.VERTICAL, false, // include legend true, // tooltips false // urls ); final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinePaint(Color.WHITE); plot.setRangeGridlinePaint(Color.WHITE); XYDotRenderer renderer = new XYDotRenderer(); renderer.setDotHeight(5); renderer.setDotWidth(5); if (selectAll) { int i = 0; for (String col : seriesList.keySet()) { if (col.equalsIgnoreCase("unGrouped")) { col = "#000000"; } renderer.setSeriesPaint(i, imgGenerator.hex2Rgb(col)); i++; } } else if (selection == null) { renderer.setPaint(Color.LIGHT_GRAY); int i = 0; for (String col : seriesList.keySet()) { if (col.equalsIgnoreCase("unGrouped")) { col = "#000000"; } renderer.setSeriesPaint(i, imgGenerator.hex2Rgb(col)); i++; } } else { int i = 0; for (String col : seriesList.keySet()) { if (col.equalsIgnoreCase("unGrouped")) { renderer.setSeriesPaint(i, Color.LIGHT_GRAY); } else { renderer.setSeriesPaint(i, imgGenerator.hex2Rgb(col)); } i++; } } plot.setRenderer(renderer); plot.setSeriesRenderingOrder(SeriesRenderingOrder.REVERSE); NumberAxis xAxis = new NumberAxis("Principal Component" + (pcaResults.getPcai() + 1)); xAxis.setVerticalTickLabels(true); boolean auto = xAxis.getAutoRangeIncludesZero(); xAxis.setAutoRangeIncludesZero(true ^ auto); NumberAxis yAxis = new NumberAxis("Principal Component" + (pcaResults.getPcaii() + 1)); yAxis.setAutoRangeIncludesZero(true ^ auto); yAxis.setTickUnit(new NumberTickUnit(1)); plot.setDomainAxis(0, xAxis); plot.setRangeAxis(0, yAxis); double MaxX = xAxis.getRange().getUpperBound(); double MinX = xAxis.getRange().getLowerBound(); double MaxY = yAxis.getRange().getUpperBound(); double MinY = yAxis.getRange().getLowerBound(); chartRenderingInfo.clear(); String imgUrl = imgGenerator.saveToFile(chart, w, h, chartRenderingInfo); PCAImageResult imgUtilRes = new PCAImageResult(); imgUtilRes.setImgString(imgUrl); imgUtilRes.setDataAreaMaxX(chartRenderingInfo.getPlotInfo().getDataArea().getMaxX()); imgUtilRes.setDataAreaMaxY(chartRenderingInfo.getPlotInfo().getDataArea().getMaxY()); imgUtilRes.setDataAreaMinY(chartRenderingInfo.getPlotInfo().getDataArea().getMinY()); imgUtilRes.setDataAreaMinX(chartRenderingInfo.getPlotInfo().getDataArea().getMinX()); imgUtilRes.setMaxX(MaxX); imgUtilRes.setMaxY(MaxY); imgUtilRes.setMinX(MinX); imgUtilRes.setMinY(MinY); return imgUtilRes; }
From source file:com.al.cellplugin.LineChart.java
/** * Creates a chart./*from ww w. jav a 2 s . com*/ * * @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:model.LineChart.java
/** * Creates a chart./*from w w w . jav a 2 s .c om*/ * * @param dataset the data for the chart. * * @return a chart. */ private JFreeChart createChart(final XYDataset dataset, final int variableOption, final String machine) { String title = ""; switch (variableOption) { case 0: title = "Quantity"; break; case 1: title = "Size"; break; default: title = "Type"; break; } // create the chart... final JFreeChart chart = ChartFactory.createXYLineChart(title + " Line Chart: " + machine, // chart title title, // x axis label "Time", // 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, 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:web.diva.server.model.PCAGenerator.java
public PCAImageResult generateChart(String path, PCAResults pcaResults, int[] subSelectionData, int[] selection, boolean zoom, boolean selectAll, String imgName, double w, double h, DivaDataset divaDataset) { XYDataset dataset = this.createDataset(pcaResults.getPoints(), subSelectionData, selection, zoom, divaDataset);/*w w w . jav a 2 s . c o m*/ final JFreeChart chart = ChartFactory.createScatterPlot("", // chart title "Principal Component" + (pcaResults.getPcai() + 1), // x axis label "Principal Component " + (pcaResults.getPcaii() + 1), // y axis label dataset, // data PlotOrientation.VERTICAL, false, // include legend true, // tooltips false // urls ); final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinePaint(Color.WHITE); plot.setRangeGridlinePaint(Color.WHITE); XYDotRenderer renderer = new XYDotRenderer(); renderer.setDotHeight(5); renderer.setDotWidth(5); if (selectAll) { int i = 0; for (String col : seriesList.keySet()) { if (col.equalsIgnoreCase("unGrouped")) { col = "#000000"; } renderer.setSeriesPaint(i, imgGenerator.hex2Rgb(col)); i++; } } else if (selection == null) { renderer.setPaint(Color.LIGHT_GRAY); int i = 0; for (String col : seriesList.keySet()) { if (col.equalsIgnoreCase("unGrouped")) { col = "#000000"; } renderer.setSeriesPaint(i, imgGenerator.hex2Rgb(col)); i++; } } else { int i = 0; for (String col : seriesList.keySet()) { if (col.equalsIgnoreCase("unGrouped")) { renderer.setSeriesPaint(i, Color.LIGHT_GRAY); } else { renderer.setSeriesPaint(i, imgGenerator.hex2Rgb(col)); } i++; } } plot.setRenderer(renderer); plot.setSeriesRenderingOrder(SeriesRenderingOrder.REVERSE); NumberAxis xAxis = new NumberAxis("Principal Component" + (pcaResults.getPcai() + 1)); xAxis.setVerticalTickLabels(true); boolean auto = xAxis.getAutoRangeIncludesZero(); xAxis.setAutoRangeIncludesZero(true ^ auto); NumberAxis yAxis = new NumberAxis("Principal Component" + (pcaResults.getPcaii() + 1)); yAxis.setAutoRangeIncludesZero(true ^ auto); yAxis.setTickUnit(new NumberTickUnit(1)); plot.setDomainAxis(0, xAxis); plot.setRangeAxis(0, yAxis); double MaxX = xAxis.getRange().getUpperBound(); double MinX = xAxis.getRange().getLowerBound(); double MaxY = yAxis.getRange().getUpperBound(); double MinY = yAxis.getRange().getLowerBound(); chartRenderingInfo.clear(); String imgUrl = imgGenerator.saveToFile(chart, w, h, path, chartRenderingInfo, imgName); PCAImageResult imgUtilRes = new PCAImageResult(); imgUtilRes.setImgString(imgUrl); imgUtilRes.setDataAreaMaxX(chartRenderingInfo.getPlotInfo().getDataArea().getMaxX()); imgUtilRes.setDataAreaMaxY(chartRenderingInfo.getPlotInfo().getDataArea().getMaxY()); imgUtilRes.setDataAreaMinY(chartRenderingInfo.getPlotInfo().getDataArea().getMinY()); imgUtilRes.setDataAreaMinX(chartRenderingInfo.getPlotInfo().getDataArea().getMinX()); imgUtilRes.setMaxX(MaxX); imgUtilRes.setMaxY(MaxY); imgUtilRes.setMinX(MinX); imgUtilRes.setMinY(MinY); return imgUtilRes; }
From source file:Chart.JFreeChartDemo.java
/** * Create a chart./* w w w . j av a 2 s .c om*/ * * @param dataset the dataset * @return the chart */ private JFreeChart createChart(XYDataset dataset) { // WHAT IS THIS LINE??? // JFreeChart chart = ChartFactory.createTimeSeriesChart(null, null, null, dataset, rootPaneCheckingEnabled, rootPaneCheckingEnabled, rootPaneCheckingEnabled) // create the chart... JFreeChart chart = ChartFactory.createXYLineChart("", // chart title "Time", // domain axis label "Range", // range axis label dataset, // initial series PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips? false // URLs? ); // 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); NumberAxis range = (NumberAxis) plot.getRangeAxis(); range.setStandardTickUnits(ticks); // 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); // //Shape theshape = ShapeUtilities.createDiamond(1); //renderer.setSeriesShape(5, theshape); // 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:kardex.graficakardex.java
public graficakardex() { datosxy.removeAllSeries();/*from w ww.j a v a2 s .c om*/ //sxy.add(x[0], y[0]); y = new double[kardex.valor.length]; y = kardex.valor; int n = y.length; for (int i = 0; i < n; i++) { sxy.add(i, y[i]); // System.out.print(x[i]+"-"+i+" "); } datosxy.addSeries(sxy); graficaxy = ChartFactory.createXYLineChart("Grafica de Stock de Producto", "transacciones", "cantidades", datosxy, PlotOrientation.VERTICAL, true, true, true); graficaxy.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) graficaxy.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); final NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); configurarDomainAxis(domainAxis); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); renderer.setDrawSeriesLineAsPath(true); } }
From source file:entrenamiento.grafica.java
public grafica() { XYSeries sxy = new XYSeries("pesos"); datosxy.removeAllSeries();//from ww w .java 2 s . c o m //sxy.add(x[0], y[0]); y = new double[Entrenamiento.valor.length]; y = Entrenamiento.valor; int n = y.length; for (int i = 0; i < n; i++) { sxy.add(i, y[i]); // System.out.print(x[i]+"-"+i+" "); } datosxy.addSeries(sxy); graficaxy = ChartFactory.createXYLineChart("Grafica de Progreso", "tiempo", "RM-pesos", datosxy, PlotOrientation.VERTICAL, true, true, true); graficaxy.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) graficaxy.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); final NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); configurarDomainAxis(domainAxis); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); renderer.setDrawSeriesLineAsPath(true); } }
From source file:entrenamiento.grafica2.java
public grafica2() { XYSeries sxy = new XYSeries("pesos"); datosxy.removeAllSeries();/*ww w .j a va2 s.co m*/ //sxy.add(x[0], y[0]); y = new double[Entrenamiento2.valor.length]; y = Entrenamiento2.valor; int n = y.length; for (int i = 0; i < n; i++) { sxy.add(i, y[i]); // System.out.print(x[i]+"-"+i+" "); } datosxy.addSeries(sxy); graficaxy = ChartFactory.createXYLineChart("Grafica de Progreso", "tiempo", "RM-pesos", datosxy, PlotOrientation.VERTICAL, true, true, true); graficaxy.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) graficaxy.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); final NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); configurarDomainAxis(domainAxis); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); renderer.setDrawSeriesLineAsPath(true); } }