List of usage examples for org.jfree.chart.plot XYPlot setBackgroundPaint
public void setBackgroundPaint(Paint paint)
From source file:org.hxzon.demo.jfreechart.DatasetVisibleDemo.java
private static JFreeChart createTimeSeriesChart(XYDataset dataset) { //DomainAxis/* w w w . ja v a 2 s. c o m*/ DateAxis timeAxis = new DateAxis(""); timeAxis.setLowerMargin(0.02); // reduce the default margins timeAxis.setUpperMargin(0.02); timeAxis.setDateFormatOverride(new SimpleDateFormat("MM-yyyy")); //RangeAxis NumberAxis valueAxis = new NumberAxis(""); valueAxis.setAutoRangeIncludesZero(false); // override default // valueAxis.setAutoRange(false); // valueAxis.setDefaultAutoRange(new Range(100, 1150)); //Renderer XYToolTipGenerator toolTipGenerator = StandardXYToolTipGenerator.getTimeSeriesInstance(); XYURLGenerator urlGenerator = null; // urlGenerator = new StandardXYURLGenerator(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false); renderer.setBaseToolTipGenerator(toolTipGenerator); renderer.setURLGenerator(urlGenerator); renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); renderer.setDrawSeriesLineAsPath(true); //Plot XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null); plot.setRenderer(renderer); 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); // plot.setRangePannable(true); //chart JFreeChart chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, true); chart.setBackgroundPaint(Color.white); return chart; }
From source file:projects.tgas.exec.HrDiagram.java
/** * Plot the HR diagram chart from the given data. * @param series//from www . j a v a 2 s .c o m * A {@link XYSeries} containing the HR diagram data. * @return * A {@link JFreeChart} containing the plot. */ private static JFreeChart getHrChart(XYSeries series) { XYSeriesCollection hrData = new XYSeriesCollection(); hrData.addSeries(series); // Set up the renderer XYLineAndShapeRenderer hrRenderer = new XYLineAndShapeRenderer(); hrRenderer.setSeriesLinesVisible(0, false); hrRenderer.setSeriesShapesVisible(0, true); hrRenderer.setSeriesShape(0, new Ellipse2D.Double(-0.5, -0.5, 1, 1)); // Configure axes NumberAxis xAxis = new NumberAxis("B - V [mag]"); xAxis.setRange(-0.5, 2.25); NumberAxis yAxis = new NumberAxis("G [mag]"); yAxis.setInverted(true); yAxis.setRange(-5, 13); // Configure plot XYPlot xyplot = new XYPlot(hrData, xAxis, yAxis, hrRenderer); xyplot.setBackgroundPaint(Color.white); JFreeChart hrChart = new JFreeChart("HR diagram of TGAS stars", xyplot); hrChart.removeLegend(); hrChart.setBackgroundPaint(Color.white); return hrChart; }
From source file:org.gwaspi.reports.PlinkReportLoaderCombined.java
private static void appendToCombinedRangePlot(CombinedRangeXYPlot combinedPlot, String chromosome, XYSeriesCollection tempChrData, boolean showlables) { XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(false, true); renderer.setSeriesPaint(0, Color.blue); renderer.setSeriesPaint(1, Color.red); renderer.setSeriesVisibleInLegend(0, showlables); renderer.setSeriesVisibleInLegend(1, showlables); //renderer.setBaseShape(new Ellipse2D.Float(0, 0, 2,2), false); if (combinedPlot.getSubplots().isEmpty()) { LogAxis rangeAxis = new LogAxis("P value"); rangeAxis.setBase(10);/*from ww w .j av a2s .c om*/ rangeAxis.setInverted(true); rangeAxis.setNumberFormatOverride(GenericReportGenerator.FORMAT_P_VALUE); rangeAxis.setTickMarkOutsideLength(2.0f); rangeAxis.setMinorTickCount(2); rangeAxis.setMinorTickMarksVisible(true); rangeAxis.setAxisLineVisible(true); rangeAxis.setAutoRangeMinimumSize(0.0000005); rangeAxis.setLowerBound(1d); //rangeAxis.setAutoRangeIncludesZero(false); combinedPlot.setRangeAxis(0, rangeAxis); } JFreeChart subchart = ChartFactory.createScatterPlot("", "Chr " + chromosome, "", tempChrData, PlotOrientation.VERTICAL, true, false, false); XYPlot subplot = (XYPlot) subchart.getPlot(); subplot.setRenderer(renderer); subplot.setBackgroundPaint(null); final Marker thresholdLine = new ValueMarker(0.0000005); thresholdLine.setPaint(Color.red); if (showlables) { thresholdLine.setLabel("P = 510??"); } thresholdLine.setLabelAnchor(RectangleAnchor.TOP_RIGHT); thresholdLine.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT); subplot.addRangeMarker(thresholdLine); NumberAxis chrAxis = (NumberAxis) subplot.getDomainAxis(); chrAxis.setAxisLineVisible(false); chrAxis.setTickLabelsVisible(false); chrAxis.setTickMarksVisible(false); chrAxis.setAutoRangeIncludesZero(false); //combinedPlot.setGap(0); combinedPlot.add(subplot, 1); }
From source file:org.matsim.contrib.dvrp.util.chart.RouteChartUtils.java
public static JFreeChart chartRoutes(List<? extends Vehicle> vehicles) { CoordDataset lData = new CoordDataset(); for (int i = 0; i < vehicles.size(); i++) { Schedule<?> schedule = vehicles.get(i).getSchedule(); lData.addSeries(Integer.toString(i), LinkSources.createLinkSource(schedule)); }/*w w w .jav a2 s .co m*/ JFreeChart chart = ChartFactory.createXYLineChart("Routes", "X", "Y", lData, PlotOrientation.VERTICAL, true, true, false); XYPlot plot = (XYPlot) chart.getPlot(); plot.setRangeGridlinesVisible(false); plot.setDomainGridlinesVisible(false); plot.setBackgroundPaint(Color.white); NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); yAxis.setAutoRangeIncludesZero(false); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setSeriesShapesVisible(0, true); renderer.setSeriesLinesVisible(0, false); renderer.setSeriesItemLabelsVisible(0, true); renderer.setBaseItemLabelGenerator(new XYItemLabelGenerator() { public String generateLabel(XYDataset dataset, int series, int item) { return ((CoordDataset) dataset).getText(series, item); } }); for (int i = 1; i <= vehicles.size(); i++) { renderer.setSeriesShapesVisible(i, true); renderer.setSeriesLinesVisible(i, true); renderer.setSeriesItemLabelsVisible(i, true); } return chart; }
From source file:org.jfree.chart.demo.BoxAndWhiskerChartDemo2.java
private static JFreeChart createChart(BoxAndWhiskerXYDataset boxandwhiskerxydataset) { DateAxis dateaxis = new DateAxis("Day"); NumberAxis numberaxis = new NumberAxis("Value"); XYBoxAndWhiskerRenderer xyboxandwhiskerrenderer = new XYBoxAndWhiskerRenderer(); XYPlot xyplot = new XYPlot(boxandwhiskerxydataset, dateaxis, numberaxis, xyboxandwhiskerrenderer); xyplot.setOrientation(PlotOrientation.HORIZONTAL); JFreeChart jfreechart = new JFreeChart("Box-and-Whisker Chart Demo 2", xyplot); jfreechart.setBackgroundPaint(Color.white); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setDomainGridlinesVisible(true); xyplot.setRangeGridlinePaint(Color.white); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return jfreechart; }
From source file:org.jfree.chart.demo.YieldCurveDemo.java
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("US$ Treasury Yields", "Date", "Yield", xydataset, false, true, false); jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); GregorianCalendar gregoriancalendar = new GregorianCalendar(2005, 10, 15); xyplot.setDomainAxis(new CustomDateAxis("Date", gregoriancalendar.getTime())); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); xyplot.setDomainCrosshairVisible(true); xyplot.setRangeCrosshairVisible(true); org.jfree.chart.renderer.xy.XYItemRenderer xyitemrenderer = xyplot.getRenderer(); if (xyitemrenderer instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyitemrenderer; xylineandshaperenderer.setBaseShapesVisible(true); xylineandshaperenderer.setBaseShapesFilled(true); }//from w w w. j a v a2 s . c om DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis(); dateaxis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); jfreechart.addSubtitle(new TextTitle("November 2005")); TextTitle texttitle = new TextTitle("Source: http://www.econstats.com/r/r_am1.htm"); texttitle.setFont(new Font("Dialog", 0, 9)); texttitle.setPosition(RectangleEdge.BOTTOM); texttitle.setHorizontalAlignment(HorizontalAlignment.RIGHT); jfreechart.addSubtitle(texttitle); return jfreechart; }
From source file:org.matsim.contrib.dvrp.util.chart.RouteCharts.java
public static JFreeChart chartRoutes(Collection<? extends Vehicle> vehicles) { CoordDataset lData = new CoordDataset(); int i = 0;/* w w w . java 2s . co m*/ for (Vehicle v : vehicles) { Schedule schedule = v.getSchedule(); lData.addSeries(Integer.toString(i++), ScheduleCoordSources.createCoordSource(schedule)); } JFreeChart chart = ChartFactory.createXYLineChart("Routes", "X", "Y", lData, PlotOrientation.VERTICAL, true, true, false); XYPlot plot = (XYPlot) chart.getPlot(); plot.setRangeGridlinesVisible(false); plot.setDomainGridlinesVisible(false); plot.setBackgroundPaint(Color.white); NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); yAxis.setAutoRangeIncludesZero(false); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setSeriesShapesVisible(0, true); renderer.setSeriesLinesVisible(0, false); renderer.setSeriesItemLabelsVisible(0, true); renderer.setBaseItemLabelGenerator(new XYItemLabelGenerator() { public String generateLabel(XYDataset dataset, int series, int item) { return ((CoordDataset) dataset).getText(series, item); } }); for (int j = 1; j <= vehicles.size(); j++) { renderer.setSeriesShapesVisible(j, true); renderer.setSeriesLinesVisible(j, true); renderer.setSeriesItemLabelsVisible(j, true); } return chart; }
From source file:net.imglib2.script.analysis.Histogram.java
static private final void setBackgroundDefault(final JFreeChart chart) { BasicStroke gridStroke = new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 2.0f, 1.0f }, 0.0f); XYPlot plot = (XYPlot) chart.getPlot(); plot.setRangeGridlineStroke(gridStroke); plot.setDomainGridlineStroke(gridStroke); plot.setBackgroundPaint(new Color(235, 235, 235)); plot.setRangeGridlinePaint(Color.white); plot.setDomainGridlinePaint(Color.white); plot.setOutlineVisible(false);//from w w w .ja v a 2s .com plot.getDomainAxis().setAxisLineVisible(false); plot.getRangeAxis().setAxisLineVisible(false); plot.getDomainAxis().setLabelPaint(Color.gray); plot.getRangeAxis().setLabelPaint(Color.gray); plot.getDomainAxis().setTickLabelPaint(Color.gray); plot.getRangeAxis().setTickLabelPaint(Color.gray); chart.getTitle().setPaint(Color.gray); }
From source file:org.matsim.contrib.dvrp.util.chart.RouteChartUtils.java
public static JFreeChart chartRoutesByStatus(List<? extends Vehicle> vehicles) { CoordDataset nData = new CoordDataset(); for (int i = 0; i < vehicles.size(); i++) { Schedule<?> schedule = vehicles.get(i).getSchedule(); Map<TaskStatus, CoordSource> vsByStatus = createLinkSourceByStatus(schedule); nData.addSeries(i + "-PR", vsByStatus.get(TaskStatus.PERFORMED)); nData.addSeries(i + "-ST", vsByStatus.get(TaskStatus.STARTED)); nData.addSeries(i + "-PL", vsByStatus.get(TaskStatus.PLANNED)); }/*from w w w . j a v a 2s.c om*/ JFreeChart chart = ChartFactory.createXYLineChart("Routes", "X", "Y", nData, PlotOrientation.VERTICAL, false, true, false); XYPlot plot = (XYPlot) chart.getPlot(); plot.setRangeGridlinesVisible(false); plot.setDomainGridlinesVisible(false); plot.setBackgroundPaint(Color.white); NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); yAxis.setAutoRangeIncludesZero(false); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setSeriesShapesVisible(0, true); renderer.setSeriesLinesVisible(0, false); renderer.setSeriesItemLabelsVisible(0, true); renderer.setBaseItemLabelGenerator(new LabelGenerator()); Paint[] paints = DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE; Shape[] shapes = DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE; for (int i = 0; i < vehicles.size(); i++) { int s = 3 * i; renderer.setSeriesItemLabelsVisible(s + 1, true); renderer.setSeriesItemLabelsVisible(s + 2, true); renderer.setSeriesItemLabelsVisible(s + 3, true); renderer.setSeriesShapesVisible(s + 1, true); renderer.setSeriesShapesVisible(s + 2, true); renderer.setSeriesShapesVisible(s + 3, true); renderer.setSeriesLinesVisible(s + 1, true); renderer.setSeriesLinesVisible(s + 2, true); renderer.setSeriesLinesVisible(s + 3, true); renderer.setSeriesPaint(s + 1, paints[(i + 1) % paints.length]); renderer.setSeriesPaint(s + 2, paints[(i + 1) % paints.length]); renderer.setSeriesPaint(s + 3, paints[(i + 1) % paints.length]); renderer.setSeriesShape(s + 1, shapes[(i + 1) % shapes.length]); renderer.setSeriesShape(s + 2, shapes[(i + 1) % shapes.length]); renderer.setSeriesShape(s + 3, shapes[(i + 1) % shapes.length]); renderer.setSeriesStroke(s + 2, new BasicStroke(3)); renderer.setSeriesStroke(s + 3, new BasicStroke(1, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1, new float[] { 5f, 5f }, 0)); } return chart; }
From source file:es.bsc.autonomic.powermodeller.graphics.TotalPowerVsTotalPrediction.java
public static JPanel createPanel() { //Axis configuration NumberAxis sampleAxis = new NumberAxis("Sample"); sampleAxis.setAutoRangeIncludesZero(false); NumberAxis powerAxis = new NumberAxis("Power (Watts)"); powerAxis.setAutoRangeIncludesZero(false); XYSplineRenderer xysplinerenderer = new XYSplineRenderer(); XYPlot xyplot = new XYPlot(data, sampleAxis, powerAxis, xysplinerenderer); for (int i = 0; i < data.getSeriesCount(); i++) { xyplot.getRenderer().setSeriesShape(i, new Rectangle()); }//from ww w.j a va 2 s .co m //Panel layout configuration xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); xyplot.setAxisOffset(new RectangleInsets(4D, 4D, 4D, 4D)); JFreeChart jfreechart = new JFreeChart(NAME, JFreeChart.DEFAULT_TITLE_FONT, xyplot, true); ChartUtilities.applyCurrentTheme(jfreechart); ChartPanel chartpanel = new ChartPanel(jfreechart); return chartpanel; }