List of usage examples for org.jfree.chart.plot XYPlot getDomainAxis
public ValueAxis getDomainAxis()
From source file:com.bpd.jfreechart.StackedAreaChartDemo.java
/** * Customizes the JFreeChart./*from w ww . j a v a2s. c om*/ * * @param chart The chart to customize. */ private static void customizeChart(JFreeChart chart) { StackedXYAreaRenderer2 renderer = (StackedXYAreaRenderer2) chart.getXYPlot().getRenderer(); renderer.setSeriesPaint(0, Color.RED); renderer.setSeriesPaint(1, Color.BLUE); XYPlot plot = chart.getXYPlot(); plot.getDomainAxis().setLowerMargin(0.0); plot.getDomainAxis().setUpperMargin(0.0); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinePaint(Color.WHITE); plot.setRangeGridlinePaint(Color.BLACK); }
From source file:org.physionet.graphics.Plot.java
private static JFreeChart createChart(XYDataset dataset, String title, String timeLabel, String amplitudeLabel) {//from w ww.j a v a 2 s . c o m // create the chart... JFreeChart chart = ChartFactory.createXYLineChart(title, // chart title timeLabel, // x axis label amplitudeLabel, // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); XYPlot plot = (XYPlot) chart.getPlot(); plot.getDomainAxis().setLowerMargin(0.0); plot.getDomainAxis().setUpperMargin(0.0); return chart; }
From source file:inflor.core.utils.ChartUtils.java
public static Point2D getPlotCoordinates(MouseEvent e, FCSChartPanel panel) { Point2D p = panel.translateScreenToJava2D(e.getPoint()); Rectangle2D plotArea = panel.getScreenDataArea(); XYPlot plot = panel.getChart().getXYPlot(); double x = plot.getDomainAxis().java2DToValue(p.getX(), plotArea, plot.getDomainAxisEdge()); double y = plot.getRangeAxis().java2DToValue(p.getY(), plotArea, plot.getRangeAxisEdge()); return new Point2D.Double(x, y); }
From source file:org.physionet.wfdb.examples.PlotECGQRSDemo2.java
private static JFreeChart createChart(XYDataset dataset) { // create the chart... JFreeChart chart = ChartFactory.createXYLineChart("Plot ECG Demo1 ", // chart title "Time (seconds)", // x axis label "mV", // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls );/* www.j ava 2s . c o m*/ XYPlot plot = (XYPlot) chart.getPlot(); plot.getDomainAxis().setLowerMargin(0.0); plot.getDomainAxis().setUpperMargin(0.0); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setSeriesLinesVisible(1, false); renderer.setSeriesShapesVisible(1, true); renderer.setSeriesShapesFilled(1, true); } return chart; }
From source file:org.gephi.statistics.plugin.ChartUtils.java
public static void scaleChart(JFreeChart chart, XYSeries dSeries, boolean normalized) { XYPlot plot = (XYPlot) chart.getPlot(); ValueAxis domainAxis = plot.getDomainAxis(); domainAxis.setLowerMargin(1.0);//from w w w . j a v a 2s . co m domainAxis.setUpperMargin(1.0); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); if (normalized) { domainAxis.setRange(-0.05, 1.05); } else { domainAxis.setRange(dSeries.getMinX() - 1, dSeries.getMaxX() + 1); } NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setRange(-0.1 * Math.sqrt(dSeries.getMaxY()), dSeries.getMaxY() + 0.1 * Math.sqrt(dSeries.getMaxY())); }
From source file:org.codehaus.mojo.chronos.chart.ChartUtil.java
public static XYPlot setUpperBound(JFreeChart chart, double max) { XYPlot plot = chart.getXYPlot(); ValueAxis axis = (ValueAxis) plot.getDomainAxis(); axis.setUpperBound(max);//w w w.j a v a 2 s. com return plot; }
From source file:org.jfree.chart.demo.XYAreaRenderer2Demo1.java
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createXYAreaChart("XYAreaRenderer2Demo1", "Domain (X)", "Range (Y)", xydataset, PlotOrientation.VERTICAL, true, true, false); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setRenderer(new XYAreaRenderer2()); xyplot.setForegroundAlpha(0.65F);//from w ww . j a v a 2s . c o m ValueAxis valueaxis = xyplot.getDomainAxis(); valueaxis.setTickMarkPaint(Color.black); valueaxis.setLowerMargin(0.0D); valueaxis.setUpperMargin(0.0D); ValueAxis valueaxis1 = xyplot.getRangeAxis(); valueaxis1.setTickMarkPaint(Color.black); return jfreechart; }
From source file:org.codehaus.mojo.chronos.chart.ChartUtil.java
public static XYPlot setupXYPlot(JFreeChart chart, DateFormat dateFormat) { XYPlot plot = chart.getXYPlot(); DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(dateFormat); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return plot;/* w w w . jav a2s. c om*/ }
From source file:org.radargun.reporting.BarPlotGenerator.java
/** * @param operation Name of the plotted operation * @param ranges ranges[0] = min, ranges[ranges.length - 1] = max * @param counts counts[i] is number of entries with value >= ranges[i - 1] and < ranges[i] * @param reportDir/* w w w. ja v a 2s . c om*/ * @param filename * @throws IOException */ public static void generate(String operation, long[] ranges, long[] counts, String reportDir, String filename) throws IOException { XYSeries series = new XYSeries(operation + " response times"); long totalCount = 0; for (long count : counts) { totalCount += count; } double left = Math.log10(ranges[0]); double right = Math.log10(ranges[ranges.length - 1]); for (int i = 0; i < counts.length; i++) { series.add(Math.log10(ranges[i]), (double) counts[i] / totalCount); } series.add(right, 0d); XYDataset dataset = new XYSeriesCollection(series); JFreeChart chart = ChartFactory.createXYStepAreaChart(operation + " response time histogram", "Response time", "Percentage", dataset, PlotOrientation.VERTICAL, false, false, false); XYPlot plot = (XYPlot) chart.getPlot(); NumberAxis d = (NumberAxis) plot.getDomainAxis(); d.setRange(left, right); d.setStandardTickUnits(new HistoTickUnitSource()); plot.setDomainAxis(d); FileOutputStream output = new FileOutputStream(new File(reportDir + File.separator + filename)); ChartUtilities.writeChartAsPNG(output, chart, 1024, 768); output.close(); }
From source file:org.jax.maanova.plot.PlotUtil.java
/** * Rescales the XY plot to match the viewing area * @param viewArea//from ww w . j a va2s. c om * the viewing area (null means we should use autorange) * @param plot * the plot to rescale */ public static void rescaleXYPlot(final Rectangle2D viewArea, final XYPlot plot) { if (viewArea == null) { plot.getDomainAxis().setAutoRange(true); plot.getRangeAxis().setAutoRange(true); } else { plot.getDomainAxis().setRange(new Range(viewArea.getMinX(), viewArea.getMaxX()), true, false); plot.getRangeAxis().setRange(new Range(viewArea.getMinY(), viewArea.getMaxY()), true, true); } }