List of usage examples for org.jfree.chart.plot XYPlot setRenderer
public void setRenderer(XYItemRenderer renderer)
From source file:org.jfree.chart.demo.XYStepAreaRendererDemo1.java
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createXYLineChart("XYStepAreaRenderer Demo 1", "X", "Y", xydataset, PlotOrientation.VERTICAL, true, true, false); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); XYStepAreaRenderer xysteparearenderer = new XYStepAreaRenderer(2); xysteparearenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); xysteparearenderer.setDefaultEntityRadius(6); xyplot.setRenderer(xysteparearenderer); return jfreechart; }
From source file:org.jfree.chart.demo.YIntervalChartDemo1.java
private static JFreeChart createChart(IntervalXYDataset intervalxydataset) { JFreeChart jfreechart = ChartFactory.createScatterPlot("Y Interval Chart Demo", "X", "Y", intervalxydataset, PlotOrientation.VERTICAL, true, true, false); jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); xyplot.setAxisOffset(new RectangleInsets(4D, 4D, 4D, 4D)); xyplot.setRenderer(new YIntervalRenderer()); return jfreechart; }
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);//ww w . jav a2 s . c o m 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.gwaspi.reports.PlinkReportLoader.java
private static void appendToCombinedRangePlot(CombinedRangeXYPlot combinedPlot, String chromosome, XYSeriesCollection seriesCol) {/*from ww w . j a va2s . c o m*/ XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(false, true); renderer.setSeriesPaint(0, Color.blue); JFreeChart subchart = ChartFactory.createScatterPlot("", "Chr " + chromosome, "", seriesCol, PlotOrientation.VERTICAL, true, false, false); XYPlot subplot = (XYPlot) subchart.getPlot(); subplot.setRenderer(renderer); subplot.setBackgroundPaint(null); subplot.setDomainGridlineStroke(new BasicStroke(0.0f)); subplot.setDomainMinorGridlineStroke(new BasicStroke(0.0f)); subplot.setDomainGridlinePaint(Color.blue); subplot.setRangeGridlineStroke(new BasicStroke(0.0f)); subplot.setRangeMinorGridlineStroke(new BasicStroke(0.0f)); subplot.setRangeGridlinePaint(Color.blue); NumberAxis chrAxis = (NumberAxis) subplot.getDomainAxis(); chrAxis.setAxisLineVisible(true); chrAxis.setTickLabelsVisible(true); chrAxis.setTickMarksVisible(true); chrAxis.setTickUnit(new NumberTickUnit(10000)); chrAxis.setAutoRangeIncludesZero(false); NumberAxis log10Axis = (NumberAxis) subplot.getRangeAxis(); log10Axis.setTickMarkInsideLength(2.0f); log10Axis.setTickMarkOutsideLength(2.0f); log10Axis.setMinorTickCount(2); log10Axis.setMinorTickMarksVisible(true); log10Axis.setAxisLineVisible(true); log10Axis.setAutoRangeIncludesZero(false); XYItemRenderer lblRenderer = subplot.getRenderer(); MySeriesItemLabelGenerator lblGenerator = new MySeriesItemLabelGenerator(4.0d, chromosome); lblRenderer.setSeriesItemLabelGenerator(0, lblGenerator); lblRenderer.setSeriesItemLabelGenerator(1, lblGenerator); lblRenderer.setSeriesItemLabelFont(0, new Font("Serif", Font.PLAIN, 12)); lblRenderer.setSeriesItemLabelFont(1, new Font("Serif", Font.PLAIN, 12)); lblRenderer.setSeriesPositiveItemLabelPosition(0, new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.BOTTOM_LEFT, TextAnchor.TOP_LEFT, -Math.PI / 4.0)); lblRenderer.setSeriesPositiveItemLabelPosition(1, new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.BOTTOM_LEFT, TextAnchor.TOP_LEFT, -Math.PI / 4.0)); lblRenderer.setSeriesItemLabelsVisible(0, true); lblRenderer.setSeriesItemLabelsVisible(1, true); combinedPlot.add(subplot, 1); }
From source file:com.jolbox.benchmark.BenchmarkMain.java
/** * @param results//from w w w . j a v a2 s . c o m * @param delay * @param statementBenchmark * @param noC3P0 */ private static void doPlotLineGraph(long[][] results, int delay, boolean statementBenchmark, boolean noC3P0) { XYSeriesCollection dataset = new XYSeriesCollection(); for (int i = 0; i < ConnectionPoolType.values().length; i++) { // if (!ConnectionPoolType.values()[i].isEnabled() || (noC3P0 && ConnectionPoolType.values()[i].equals(ConnectionPoolType.C3P0))) { continue; } XYSeries series = new XYSeries(ConnectionPoolType.values()[i].toString()); for (int j = 1 + BenchmarkTests.stepping; j < results[i].length; j += BenchmarkTests.stepping) { series.add(j, results[i][j]); } dataset.addSeries(series); } // Generate the graph String title = "Multi-Thread test (" + delay + "ms delay)"; if (statementBenchmark) { title += "\n(with PreparedStatements tests)"; } JFreeChart chart = ChartFactory.createXYLineChart(title, // Title "threads", // x-axis Label "time (ns)", // y-axis Label dataset, // Dataset PlotOrientation.VERTICAL, // Plot Orientation true, // Show Legend true, // Use tooltips false // Configure chart to generate URLs? ); XYPlot plot = (XYPlot) chart.getPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false); plot.setRenderer(renderer); renderer.setSeriesPaint(0, Color.BLUE); renderer.setSeriesPaint(1, Color.YELLOW); renderer.setSeriesPaint(2, Color.BLACK); renderer.setSeriesPaint(3, Color.DARK_GRAY); renderer.setSeriesPaint(4, Color.MAGENTA); renderer.setSeriesPaint(5, Color.RED); renderer.setSeriesPaint(6, Color.LIGHT_GRAY); // renderer.setSeriesShapesVisible(1, true); // renderer.setSeriesShapesVisible(2, true); try { String fname = System.getProperty("java.io.tmpdir") + File.separator + "bonecp-multithread-" + delay + "ms-delay"; if (statementBenchmark) { fname += "-with-preparedstatements"; } fname += "-poolsize-" + BenchmarkTests.pool_size + "-threads-" + BenchmarkTests.threads; if (noC3P0) { fname += "-noC3P0"; } fname += ".png"; ChartUtilities.saveChartAsPNG(new File(fname), chart, 1024, 768); System.out.println("******* Saved chart to: " + fname); } catch (IOException e) { System.err.println("Problem occurred creating chart."); } }
From source file:org.hxzon.demo.jfreechart.DatasetVisibleDemo3.java
private static JFreeChart createTimeSeriesChart() { XYDataset dataset1 = createDataset1(); //DomainAxis/*w w w.j a va 2 s . co 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 NumberAxis valueAxis2 = new NumberAxis(""); valueAxis2.setAutoRangeIncludesZero(false); // override default // valueAxis.setDefaultAutoRange(new Range(100, 1150)); //Renderer XYToolTipGenerator toolTipGenerator = StandardXYToolTipGenerator.getTimeSeriesInstance(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false); renderer.setBaseToolTipGenerator(toolTipGenerator); renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); renderer.setDrawSeriesLineAsPath(true); XYDataset dataset2 = createDataset2(); XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer(true, false); //Plot XYPlot plot = new XYPlot(dataset1, timeAxis, valueAxis, null); plot.setRenderer(renderer); plot.setDataset(1, dataset2); plot.setRenderer(1, renderer2); plot.setRangeAxis(1, valueAxis2); plot.mapDatasetToRangeAxis(1, 1); plot.setBackgroundPaint(plotBackgroundPaint); 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); valueAxis.setAutoRange(false); timeAxis.setAutoRange(false); return chart; }
From source file:com.jolbox.benchmark.BenchmarkLaunch.java
/** * @param results/*from w w w .j a v a2s .c o m*/ * @param delay * @param statementBenchmark * @param noC3P0 * @throws IOException */ private static void doPlotLineGraph(long[][] results, int delay, boolean statementBenchmark, boolean noC3P0) throws IOException { String title = "Multi-Thread test (" + delay + "ms delay)"; if (statementBenchmark) { title += "\n(with PreparedStatements tests)"; } String fname = System.getProperty("java.io.tmpdir") + File.separator + "bonecp-multithread-" + delay + "ms-delay"; if (statementBenchmark) { fname += "-with-preparedstatements"; } fname += "-poolsize-" + BenchmarkTests.pool_size + "-threads-" + BenchmarkTests.threads; if (noC3P0) { fname += "-noC3P0"; } PrintWriter out = new PrintWriter(new FileWriter(fname + ".txt")); fname += ".png"; XYSeriesCollection dataset = new XYSeriesCollection(); for (int i = 0; i < ConnectionPoolType.values().length; i++) { // if (!ConnectionPoolType.values()[i].isEnabled() || (noC3P0 && ConnectionPoolType.values()[i].equals(ConnectionPoolType.C3P0))) { continue; } XYSeries series = new XYSeries(ConnectionPoolType.values()[i].toString()); out.println(ConnectionPoolType.values()[i].toString()); for (int j = 1 + BenchmarkTests.stepping; j < results[i].length; j += BenchmarkTests.stepping) { series.add(j, results[i][j]); out.println(j + "," + results[i][j]); } dataset.addSeries(series); } out.close(); // Generate the graph JFreeChart chart = ChartFactory.createXYLineChart(title, // Title "threads", // x-axis Label "time (ns)", // y-axis Label dataset, // Dataset PlotOrientation.VERTICAL, // Plot Orientation true, // Show Legend true, // Use tooltips false // Configure chart to generate URLs? ); XYPlot plot = (XYPlot) chart.getPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false); plot.setRenderer(renderer); renderer.setSeriesPaint(0, Color.BLUE); renderer.setSeriesPaint(1, Color.YELLOW); renderer.setSeriesPaint(2, Color.BLACK); renderer.setSeriesPaint(3, Color.DARK_GRAY); renderer.setSeriesPaint(4, Color.MAGENTA); renderer.setSeriesPaint(5, Color.RED); renderer.setSeriesPaint(6, Color.LIGHT_GRAY); // renderer.setSeriesShapesVisible(1, true); // renderer.setSeriesShapesVisible(2, true); try { ChartUtilities.saveChartAsPNG(new File(fname), chart, 1024, 768); System.out.println("******* Saved chart to: " + fname); } catch (IOException e) { System.err.println("Problem occurred creating chart."); } }
From source file:org.jfree.chart.demo.ClusteredXYBarRendererDemo1.java
private static JFreeChart createChart(String s, IntervalXYDataset intervalxydataset) { JFreeChart jfreechart = ChartFactory.createXYBarChart(s, null, true, "Y", intervalxydataset, PlotOrientation.VERTICAL, true, true, false); jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); ClusteredXYBarRenderer clusteredxybarrenderer = new ClusteredXYBarRenderer(0.20000000000000001D, false); xyplot.setRenderer(clusteredxybarrenderer); return jfreechart; }
From source file:org.jfree.chart.demo.XYLine3DRendererDemo1.java
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createXYLineChart("XYLine3DRenderer Demo 1", "X", "Y", xydataset, PlotOrientation.VERTICAL, true, true, false); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); XYLine3DRenderer xyline3drenderer = new XYLine3DRenderer(); xyline3drenderer.setWallPaint(Color.gray); xyline3drenderer.setXOffset(2D);//ww w . j ava2s .c o m xyline3drenderer.setYOffset(3D); xyline3drenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); xyline3drenderer.setDefaultEntityRadius(6); xyplot.setRenderer(xyline3drenderer); return jfreechart; }
From source file:com.moczul.jbacktester.Main.java
private static void showChart(XYDataset dataset) { final JFreeChart chart = ChartFactory.createXYLineChart("PKO - PEO", // chart title "X", // x axis label "Y", // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls );/*ww w. j ava 2 s . c o m*/ final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); XYPlot plot = chart.getXYPlot(); final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, false); renderer.setSeriesLinesVisible(1, false); renderer.setSeriesShapesVisible(2, false); renderer.setSeriesShapesVisible(3, false); renderer.setSeriesShapesVisible(4, false); plot.setRenderer(renderer); JFrame frame = new JFrame(); frame.setContentPane(chartPanel); frame.pack(); frame.setVisible(true); }