List of usage examples for org.jfree.chart.plot XYPlot setDomainGridlinePaint
public void setDomainGridlinePaint(Paint paint)
From source file:model.LineChart.java
/** * Creates a chart.//from w w w. j av a2 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 a2 s. co 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:kardex.graficakardex.java
public graficakardex() { datosxy.removeAllSeries();/*from ww w . j av a 2 s . com*/ //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();/* www . j av a2 s .c om*/ //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();/*from w w w. j av a 2 s . c om*/ //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); } }
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:CargarEntrenamiento.grafica2.java
public grafica2() { datosxy.removeAllSeries();//from www .j ava2 s. co m XYSeries sxy = new XYSeries("pesos"); //sxy.add(x[0], y[0]); y = new double[cargarEntreno.valorentreno.length]; y = cargarEntreno.valorentreno; 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:edu.ucla.stat.SOCR.chart.demo.QQData2DataDemo.java
/** * Creates a chart.//from w ww.j a va 2 s . co m * * @param dataset the data for the chart. * * @return a chart. */ protected JFreeChart createChart(XYDataset dataset) { // create the chart... JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, //"Data vs Data Q-Q plot", // 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.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); // renderer.setShapesVisible(true); renderer.setBaseShapesFilled(true); // renderer.setLinesVisible(false); renderer.setSeriesLinesVisible(1, true); renderer.setSeriesShapesVisible(1, false); renderer.setSeriesLinesVisible(0, false); renderer.setSeriesShapesVisible(0, true); //renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator()); // change the auto tick unit selection to integer units only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setAutoRangeIncludesZero(false); rangeAxis.setUpperMargin(0.02); rangeAxis.setLowerMargin(0.02); // rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setAutoRangeIncludesZero(false); domainAxis.setUpperMargin(0.02); domainAxis.setLowerMargin(0.02); // domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // OPTIONAL CUSTOMISATION COMPLETED. setQQSummary(dataset); return chart; }
From source file:loldmg.GUI.MainFrame.java
private JFreeChart createChart(final XYDataset dataset) { // create the chart... final JFreeChart newchart = ChartFactory.createXYLineChart("Auto Attack DPS", // chart title "Level", // x axis label "Damage", // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls );/* w w w. j a v a2s . c o m*/ // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... newchart.setBackgroundPaint(Color.GRAY); // get a reference to the plot for further customisation... final XYPlot plot = newchart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); 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()); // OPTIONAL CUSTOMISATION COMPLETED. return newchart; }
From source file:com.itemanalysis.jmetrik.graph.histogram.HistogramPanel.java
public void setGraph() { HistogramChartDataset dataset = null; dataset = new HistogramChartDataset(); chart = HistogramChart.createHistogram(chartTitle, xlabel, //x-axis label ylabel, //y-axis label dataset, chartOrientation, hasGroupingVariable, //legend true, //tooltips false //urls );// w w w .j a va2 s. c o m if (chartSubtitle != null && !"".equals(chartSubtitle)) { TextTitle subtitle1 = new TextTitle(); chart.addSubtitle(subtitle1); } XYPlot plot = (XYPlot) chart.getPlot(); if (hasGroupingVariable) plot.setForegroundAlpha(0.80f); plot.setBackgroundPaint(Color.WHITE); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); plot.setDomainGridlinePaint(Color.LIGHT_GRAY); XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(true); renderer.setShadowVisible(false); //next two lines are temp setting for book //these two lines will create a histogram with white bars so it appears as just the bar outline // renderer.setBarPainter(new StandardXYBarPainter()); // renderer.setSeriesPaint(0, Color.white); ChartPanel panel = new ChartPanel(chart); panel.getPopupMenu().addSeparator(); this.addJpgMenuItem(this, panel.getPopupMenu()); panel.setPreferredSize(new Dimension(width, height)); // //temp setting for book // this.addLocalEPSMenuItem(this, panel.getPopupMenu(), chart);//remove this line for public release versions chart.setPadding(new RectangleInsets(20.0, 5.0, 20.0, 5.0)); this.setBackground(Color.WHITE); this.add(panel); }