List of usage examples for org.jfree.chart.plot XYPlot setBackgroundPaint
public void setBackgroundPaint(Paint paint)
From source file:grafix.graficos.eixos.Eixo.java
protected void configurarPlot(final XYPlot plot) { NumberAxis nAxis = definirEixoVertical(); plot.setRangeAxis(nAxis);//from w ww . j a va 2 s. c o m plot.setBackgroundPaint(Color.white); plot.setRangeGridlinesVisible(this.isGradeHorizontal()); plot.setRangeGridlinePaint(this.getCorGradeHorizontal()); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); incluirLegenda(plot); incluirEixoX(plot); configurarEscalaVertical(plot); }
From source file:ec.nbdemetra.chainlinking.outlineview.ChainLinkingChart.java
@Override protected void onColorSchemeChange() { XYPlot plot = chartPanel.getChart().getXYPlot(); if (plot.getDataset() != null) { for (int i = 0; i < plot.getDataset().getSeriesCount(); i++) { plot.getRenderer().setSeriesPaint(i, themeSupport.getLineColor(i)); }//www. j a v a 2 s . c om } plot.setBackgroundPaint(themeSupport.getPlotColor()); plot.setDomainGridlinePaint(themeSupport.getGridColor()); plot.setRangeGridlinePaint(themeSupport.getGridColor()); chartPanel.getChart().setBackgroundPaint(themeSupport.getBackColor()); }
From source file:com.rapidminer.gui.plotter.DistributionPlotter.java
private JFreeChart createNumericalChart() { JFreeChart chart;/*from ww w . j a va 2s . c o m*/ XYDataset dataset = createNumericalDataSet(); // create the chart... chart = ChartFactory.createXYLineChart(null, // chart title "value", // x axis label "density", // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); 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.LIGHT_GRAY); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); DeviationRenderer renderer = new DeviationRenderer(true, false); Stroke stroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND); if (dataset.getSeriesCount() == 1) { renderer.setSeriesStroke(0, stroke); renderer.setSeriesPaint(0, Color.RED); renderer.setSeriesFillPaint(0, Color.RED); } else { for (int i = 0; i < dataset.getSeriesCount(); i++) { renderer.setSeriesStroke(i, stroke); Color color = getPointColor((double) i / (double) (dataset.getSeriesCount() - 1)); renderer.setSeriesPaint(i, color); renderer.setSeriesFillPaint(i, color); } } renderer.setAlpha(0.12f); plot.setRenderer(renderer); NumberAxis xAxis = (NumberAxis) plot.getDomainAxis(); xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return chart; }
From source file:edu.ucla.stat.SOCR.chart.SuperDotChart.java
/** * Creates a chart.//from w w w . j a v a 2 s . c om * * @param dataset the dataset. * * @return a chart. */ protected JFreeChart createChart1(XYDataset dataset) { // create the chart... JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, // chart title domainLabel, // x axis label rangeLabel, // y axis label dataset, // data PlotOrientation.HORIZONTAL, !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); // change the auto tick unit selection to integer units only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:graficoComparacion.graficaCompa.java
public graficaCompa() { //sxy.add(x[0], y[0]); /////////////// /* s1.add(new Month(4, 2001), 153.8); s1.add(new Month(5, 2001), 167.6); s1.add(new Month(6, 2001), 158.8); s1.add(new Month(7, 2001), 148.3); s1.add(new Month(8, 2001), 153.9); s1.add(new Month(9, 2001), 142.7); s1.add(new Month(10, 2001), 123.2); ////////////////////////////////////// datos.addSeries(s1);// w ww .j a va 2 s. c o m */ grafica = ChartFactory.createTimeSeriesChart("Progreso de cargas", "Fechas", "Peso", datos, true, true, false); /// grafica.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) grafica.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); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); renderer.setDrawSeriesLineAsPath(true); } DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); }
From source file:projects.upc.exec.HrDiagram.java
/** * Update the {@link HrDiagram#chartPanel}. *//*from w ww .j ava 2s . c om*/ private void updateChart() { XYSeries series = new XYSeries("UPC HR diagram"); for (Entry<UpcStar, SsaCrossMatch> xm : starsToPlot.entrySet()) { UpcStar upcStar = xm.getKey(); SsaCrossMatch ssa = xm.getValue(); // Get the SSA colours of the UPC star double b = ssa.ssaB; double r2 = ssa.ssaR2; // double i = ssa.ssaI; // Use the parallax to correct the apparent magnitude to absolute magnitude. // Extract the parallax and error to use double p = (useHip && upcStar.isHipparcosStar()) ? upcStar.srcPi : upcStar.absPi; double sigma_p = (useHip && upcStar.isHipparcosStar()) ? upcStar.srcPiErr : upcStar.absPiErr; // Filter on the fractional parallax error double f = sigma_p / p; if (f > fMax) { continue; } // Correct to arcseconds p /= 1000; sigma_p /= 1000; // Get the distance double d = DistanceFromParallax.getDistance(p, sigma_p, method); // Filter & convert to absolute magnitude if (d > 0 && !Double.isInfinite(d)) { double B = MagnitudeUtils.getAbsoluteMagnitude(d, b); series.add(b - r2, B); } } XYSeriesCollection data = new XYSeriesCollection(); data.addSeries(series); // Set up the renderer XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, false); renderer.setSeriesShapesVisible(0, true); renderer.setSeriesShape(0, new Ellipse2D.Double(-0.5, -0.5, 1, 1)); // Configure axes NumberAxis xAxis = new NumberAxis("B - R [mag]"); xAxis.setRange(-1.0, 3.5); NumberAxis yAxis = new NumberAxis("B [mag]"); yAxis.setInverted(true); yAxis.setRange(-5, 15); // Configure plot XYPlot xyplot = new XYPlot(data, xAxis, yAxis, renderer); xyplot.setBackgroundPaint(Color.white); JFreeChart chart = new JFreeChart("HR diagram of UPC stars with SSA cross-matches", xyplot); chart.removeLegend(); chart.setBackgroundPaint(Color.white); if (chartPanel == null) { // Branch is used on initialisation chartPanel = new ChartPanel(chart); } else { chartPanel.setChart(chart); } }
From source file:imc.graficaIMC.java
public void iejmplo() { TimeSeries s1 = new TimeSeries("Entrenamiento Actual"); s1.add(new Month(2, 2001), 181.8); //s1.add(new Week(1, 1), null); s1.add(new Month(3, 2001), 167.3); s1.add(new Month(4, 2001), 153.8); s1.add(new Month(5, 2001), 167.6); s1.add(new Month(6, 2001), 158.8); s1.add(new Month(7, 2001), 148.3); s1.add(new Month(8, 2001), 153.9); s1.add(new Month(9, 2001), 142.7); s1.add(new Month(10, 2001), 123.2); s1.add(new Month(11, 2001), 131.8); s1.add(new Month(12, 2001), 139.6); s1.add(new Month(1, 2002), 142.9); s1.add(new Month(2, 2002), 138.7); s1.add(new Month(3, 2002), 137.3); s1.add(new Month(4, 2002), 143.9); s1.add(new Month(5, 2002), 139.8); s1.add(new Month(6, 2002), 137.0); s1.add(new Month(7, 2002), 132.8); TimeSeries s2 = new TimeSeries("L&G UK Index Trust"); s2.add(new Month(2, 2001), 129.6); s2.add(new Month(3, 2001), 123.2); s2.add(new Month(4, 2001), 117.2); s2.add(new Month(5, 2001), 124.1); s2.add(new Month(6, 2001), 122.6); s2.add(new Month(7, 2001), 119.2); s2.add(new Month(8, 2001), 116.5); s2.add(new Month(9, 2001), 112.7); s2.add(new Month(10, 2001), 101.5); s2.add(new Month(11, 2001), 106.1); s2.add(new Month(12, 2001), 110.3); s2.add(new Month(1, 2002), 111.7); s2.add(new Month(2, 2002), 111.0); s2.add(new Month(3, 2002), 109.6); s2.add(new Month(4, 2002), 113.2); s2.add(new Month(5, 2002), 111.6); s2.add(new Month(6, 2002), 108.8); s2.add(new Month(7, 2002), 101.6); TimeSeries s3 = new TimeSeries("andres2255"); s3.add(new Month(2, 2001), 129.6); s3.add(new Month(10, 2001), 106.1); s3.add(new Month(1, 2002), 111.7); s3.add(new Month(2, 2002), 111.0); datos.addSeries(s1);/*from w w w .j a v a 2 s .co m*/ datos.addSeries(s2); datos.addSeries(s3); grafica = ChartFactory.createTimeSeriesChart("titulo", "etiquetas X", "etiquetaY", datos, true, true, false); /// grafica.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) grafica.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); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); renderer.setDrawSeriesLineAsPath(true); } DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); }
From source file:ui.Graph.java
/** * Creates a chart./* w w w. j a va 2 s.c om*/ * * @param dataset * the data for the chart. * * @return a chart. */ private JFreeChart createChart(ArrayList<Setpoint> setpoints, ArrayList<Setpoint> traj) { trajectory = traj; XYSeries posSeries = new XYSeries("Position"); XYSeries trajSeries = new XYSeries("Trajectory"); XYSeries velSeries = new XYSeries("Velocity"); for (int i = 0; i < setpoints.size(); i++) { Setpoint p = setpoints.get(i); posSeries.add(p.time, p.position); velSeries.add(p.time, p.velocity); } for (int i = 0; i < trajectory.size(); i++) { Setpoint p = trajectory.get(i); trajSeries.add(p.time, p.position); } XYSeriesCollection posDataset = new XYSeriesCollection(); XYSeriesCollection trajDataset = new XYSeriesCollection(); XYSeriesCollection velDataset = new XYSeriesCollection(); posDataset.addSeries(posSeries); velDataset.addSeries(velSeries); trajDataset.addSeries(trajSeries); // create the chart... final JFreeChart chart = ChartFactory.createScatterPlot("System output", // chart title "X", // x axis label "Y", // y axis label posDataset, // 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.setDataset(0, posDataset); plot.setDataset(1, trajDataset); plot.setDataset(2, velDataset); plot.setBackgroundPaint(Color.white); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); XYLineAndShapeRenderer posRenderer = new XYLineAndShapeRenderer(); // renderer.setSeriesShape(0, new Ellipse2D.Float(1.0f, 1.0f, 1.0f, // 1.0f)); posRenderer.setSeriesPaint(0, Color.BLUE); posRenderer.setSeriesLinesVisible(0, true); posRenderer.setSeriesShapesVisible(0, false); XYStepRenderer trajRenderer = new XYStepRenderer(); trajRenderer.setSeriesPaint(1, Color.RED); trajRenderer.setSeriesStroke(1, new BasicStroke(10)); trajRenderer.setSeriesLinesVisible(1, true); trajRenderer.setSeriesShapesVisible(1, false); XYLineAndShapeRenderer velRenderer = new XYLineAndShapeRenderer(); velRenderer.setSeriesPaint(0, Color.MAGENTA); velRenderer.setSeriesLinesVisible(0, true); velRenderer.setSeriesShapesVisible(0, false); // renderer.setSeriesStroke(1, new BasicStroke(0.01f)); plot.setRenderer(0, posRenderer); plot.setRenderer(1, trajRenderer); plot.setRenderer(2, velRenderer); for (Setpoint s : trajectory) { Marker marker = new ValueMarker(s.time); marker.setPaint(Color.DARK_GRAY); marker.setLabel(Float.toString((float) s.position)); marker.setLabelAnchor(RectangleAnchor.TOP_LEFT); marker.setLabelTextAnchor(TextAnchor.TOP_RIGHT); plot.addDomainMarker(marker); } XYTextAnnotation p = new XYTextAnnotation("kP = " + gains.kP, plot.getDomainAxis().getUpperBound() * 0.125, plot.getRangeAxis().getUpperBound() * .75); p.setFont(new Font("Dialog", Font.PLAIN, 12)); plot.addAnnotation(p); XYTextAnnotation i = new XYTextAnnotation("kI = " + gains.kI, plot.getDomainAxis().getUpperBound() * 0.125, plot.getRangeAxis().getUpperBound() * .7); i.setFont(new Font("Dialog", Font.PLAIN, 12)); plot.addAnnotation(i); XYTextAnnotation d = new XYTextAnnotation("kD = " + gains.kD, plot.getDomainAxis().getUpperBound() * 0.125, plot.getRangeAxis().getUpperBound() * .65); d.setFont(new Font("Dialog", Font.PLAIN, 12)); plot.addAnnotation(d); // change the auto tick unit selection to integer units only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setAutoRange(true); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:se.six.jmeter.visualizer.statagg.StatAggVisualizer.java
private JFreeChart createChart() { setupDatasets();// w ww . j a va 2 s . c o m final JFreeChart chart = ChartFactory.createTimeSeriesChart(null, "Time", "ThroughPut", _dataSet1, true, true, false); final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); ValueAxis axis = plot.getDomainAxis(); axis.setAutoRange(true); //axis.setFixedAutoRange(12 * 3600 * 1000); // 12 Hours XYItemRenderer renderer1 = plot.getRenderer(); renderer1.setSeriesPaint(0, Color.BLACK); final NumberAxis axis2 = new NumberAxis("Response Time"); axis2.setAutoRangeIncludesZero(false); plot.setRangeAxis(1, axis2); plot.setDataset(1, _dataSet2); plot.mapDatasetToRangeAxis(1, 1); StandardXYItemRenderer renderer2 = new StandardXYItemRenderer(); renderer2.setSeriesPaint(0, new Color(0, 153, 255)); plot.setRenderer(1, renderer2); chart.setBackgroundPaint(Color.white); return chart; }
From source file:com.rapidminer.gui.plotter.charts.DeviationChartPlotter.java
private JFreeChart createChart(XYDataset dataset, boolean createLegend) { // create the chart... JFreeChart chart = ChartFactory.createXYLineChart(null, // chart title null, // x axis label null, // y axis label dataset, // data PlotOrientation.VERTICAL, createLegend, // include legend true, // tooltips false // urls );/* w w w . ja va2s . c o m*/ chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customization... XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.LIGHT_GRAY); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); DeviationRenderer renderer = new DeviationRenderer(true, false); Stroke stroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND); if (dataset.getSeriesCount() == 1) { renderer.setSeriesStroke(0, stroke); renderer.setSeriesPaint(0, Color.RED); renderer.setSeriesFillPaint(0, Color.RED); } else { for (int i = 0; i < dataset.getSeriesCount(); i++) { renderer.setSeriesStroke(i, stroke); Color color = getColorProvider() .getPointColor((double) i / (double) (dataset.getSeriesCount() - 1)); renderer.setSeriesPaint(i, color); renderer.setSeriesFillPaint(i, color); } } renderer.setAlpha(0.12f); plot.setRenderer(renderer); ValueAxis valueAxis = plot.getRangeAxis(); valueAxis.setLabelFont(LABEL_FONT_BOLD); valueAxis.setTickLabelFont(LABEL_FONT); return chart; }