Java Code Examples for org.jfree.chart.plot.XYPlot#setRangeAxis()
The following examples show how to use
org.jfree.chart.plot.XYPlot#setRangeAxis() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LogAxisTest.java From SIMVA-SoS with Apache License 2.0 | 6 votes |
/** * Checks that the auto-range for the domain axis on an XYPlot is * working as expected. */ @Test public void testXYAutoRange1() { XYSeries series = new XYSeries("Series 1"); series.add(1.0, 1.0); series.add(2.0, 2.0); series.add(3.0, 3.0); XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(series); JFreeChart chart = ChartFactory.createScatterPlot("Test", "X", "Y", dataset); XYPlot plot = (XYPlot) chart.getPlot(); LogAxis axis = new LogAxis("Log(Y)"); plot.setRangeAxis(axis); assertEquals(0.9465508226401592, axis.getLowerBound(), EPSILON); assertEquals(3.1694019256486126, axis.getUpperBound(), EPSILON); }
Example 2
Source File: MultipleAxisChart.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 6 votes |
public void addSeries(String yaxisName, TimeSeries series) { NumberAxis axis2 = new NumberAxis(yaxisName); axis2.setAutoRangeIncludesZero(false); XYPlot plot = (XYPlot) chart.getPlot(); plot.setRangeAxis(axisNum, axis2); plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_LEFT); TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(series); plot.setDataset(axisNum, dataset); plot.mapDatasetToRangeAxis(axisNum, axisNum); XYItemRenderer renderer2 = new StandardXYItemRenderer(); plot.setRenderer(axisNum, renderer2); axisNum++; }
Example 3
Source File: LogAxisTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Checks that the auto-range for the range axis on an XYPlot is * working as expected. */ public void testXYAutoRange2() { XYSeries series = new XYSeries("Series 1"); series.add(1.0, 1.0); series.add(2.0, 2.0); series.add(3.0, 3.0); XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(series); JFreeChart chart = ChartFactory.createScatterPlot( "Test", "X", "Y", dataset, PlotOrientation.VERTICAL, false, false, false ); XYPlot plot = (XYPlot) chart.getPlot(); LogAxis axis = new LogAxis("Log(Y)"); plot.setRangeAxis(axis); assertEquals(0.9465508226401592, axis.getLowerBound(), EPSILON); assertEquals(3.1694019256486126, axis.getUpperBound(), EPSILON); }
Example 4
Source File: LogAxisTest.java From buffer_bci with GNU General Public License v3.0 | 6 votes |
/** * Checks that the auto-range for the domain axis on an XYPlot is * working as expected. */ @Test public void testXYAutoRange1() { XYSeries series = new XYSeries("Series 1"); series.add(1.0, 1.0); series.add(2.0, 2.0); series.add(3.0, 3.0); XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(series); JFreeChart chart = ChartFactory.createScatterPlot("Test", "X", "Y", dataset); XYPlot plot = (XYPlot) chart.getPlot(); LogAxis axis = new LogAxis("Log(Y)"); plot.setRangeAxis(axis); assertEquals(0.9465508226401592, axis.getLowerBound(), EPSILON); assertEquals(3.1694019256486126, axis.getUpperBound(), EPSILON); }
Example 5
Source File: ChartPanelTest.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
/** * Checks that a call to the restoreAutoRangeBounds() method, for a plot * with more than one range axis, generates just one ChartChangeEvent. */ @Test public void test2502355_restoreAutoRangeBounds() { DefaultXYDataset dataset = new DefaultXYDataset(); JFreeChart chart = ChartFactory.createXYLineChart("TestChart", "X", "Y", dataset, PlotOrientation.VERTICAL, false, false, false); XYPlot plot = (XYPlot) chart.getPlot(); plot.setRangeAxis(1, new NumberAxis("X2")); ChartPanel panel = new ChartPanel(chart); chart.addChangeListener(this); this.chartChangeEvents.clear(); panel.restoreAutoRangeBounds(); assertEquals(1, this.chartChangeEvents.size()); }
Example 6
Source File: ChartPanelTest.java From ECG-Viewer with GNU General Public License v2.0 | 5 votes |
/** * Checks that a call to the restoreAutoRangeBounds() method, for a plot * with more than one range axis, generates just one ChartChangeEvent. */ @Test public void test2502355_restoreAutoRangeBounds() { DefaultXYDataset dataset = new DefaultXYDataset(); JFreeChart chart = ChartFactory.createXYLineChart("TestChart", "X", "Y", dataset, PlotOrientation.VERTICAL, false, false, false); XYPlot plot = (XYPlot) chart.getPlot(); plot.setRangeAxis(1, new NumberAxis("X2")); ChartPanel panel = new ChartPanel(chart); chart.addChangeListener(this); this.chartChangeEvents.clear(); panel.restoreAutoRangeBounds(); assertEquals(1, this.chartChangeEvents.size()); }
Example 7
Source File: ChartPanelTest.java From ccu-historian with GNU General Public License v3.0 | 5 votes |
/** * Checks that a call to the restoreAutoRangeBounds() method, for a plot * with more than one range axis, generates just one ChartChangeEvent. */ @Test public void test2502355_restoreAutoRangeBounds() { DefaultXYDataset dataset = new DefaultXYDataset(); JFreeChart chart = ChartFactory.createXYLineChart("TestChart", "X", "Y", dataset, PlotOrientation.VERTICAL, false, false, false); XYPlot plot = (XYPlot) chart.getPlot(); plot.setRangeAxis(1, new NumberAxis("X2")); ChartPanel panel = new ChartPanel(chart); chart.addChangeListener(this); this.chartChangeEvents.clear(); panel.restoreAutoRangeBounds(); assertEquals(1, this.chartChangeEvents.size()); }
Example 8
Source File: CombinedXYPlot.java From ECG-Viewer with GNU General Public License v2.0 | 5 votes |
/** * Sets the range axis that is shared by all the subplots. * * @param axis the axis. */ public void setRangeAxis(ValueAxis axis) { Iterator l_itr = getSubplots().iterator(); while (l_itr.hasNext()) { XYPlot l_subplot = (XYPlot) l_itr.next(); l_subplot.setRangeAxis(0, axis, false); } super.setRangeAxis(axis); if (null == axis) { return; } axis.configure(); }
Example 9
Source File: ChartPanelTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Checks that a call to the restoreAutoRangeBounds() method, for a plot * with more than one range axis, generates just one ChartChangeEvent. */ public void test2502355_restoreAutoRangeBounds() { DefaultXYDataset dataset = new DefaultXYDataset(); JFreeChart chart = ChartFactory.createXYLineChart("TestChart", "X", "Y", dataset, false); XYPlot plot = (XYPlot) chart.getPlot(); plot.setRangeAxis(1, new NumberAxis("X2")); ChartPanel panel = new ChartPanel(chart); chart.addChangeListener(this); this.chartChangeEvents.clear(); panel.restoreAutoRangeBounds(); assertEquals(1, this.chartChangeEvents.size()); }
Example 10
Source File: CombinedXYPlot.java From ccu-historian with GNU General Public License v3.0 | 5 votes |
/** * Adds a new subplot with the specified weight. * * @param subplot the subplot. * @param weight the weight for the subplot. */ public void add(XYPlot subplot, int weight) { super.add(subplot, weight); ValueAxis l_range = super.getRangeAxis(); subplot.setRangeAxis(0, l_range, false); super.setRangeAxis(l_range); if (null == l_range) { return; } l_range.configure(); }
Example 11
Source File: ChartPanelTest.java From ECG-Viewer with GNU General Public License v2.0 | 5 votes |
/** * Checks that a call to the zoomInRange() method, for a plot with more * than one range axis, generates just one ChartChangeEvent. */ @Test public void test2502355_zoomInRange() { DefaultXYDataset dataset = new DefaultXYDataset(); JFreeChart chart = ChartFactory.createXYLineChart("TestChart", "X", "Y", dataset, PlotOrientation.VERTICAL, false, false, false); XYPlot plot = (XYPlot) chart.getPlot(); plot.setRangeAxis(1, new NumberAxis("X2")); ChartPanel panel = new ChartPanel(chart); chart.addChangeListener(this); this.chartChangeEvents.clear(); panel.zoomInRange(1.0, 2.0); assertEquals(1, this.chartChangeEvents.size()); }
Example 12
Source File: CombinedXYPlot.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
/** * Adds a new subplot with the specified weight. * * @param subplot the subplot. * @param weight the weight for the subplot. */ public void add(XYPlot subplot, int weight) { super.add(subplot, weight); ValueAxis l_range = super.getRangeAxis(); subplot.setRangeAxis(0, l_range, false); super.setRangeAxis(l_range); if (null == l_range) { return; } l_range.configure(); }
Example 13
Source File: ChartPanelTest.java From SIMVA-SoS with Apache License 2.0 | 5 votes |
/** * Checks that a call to the restoreAutoRangeBounds() method, for a plot * with more than one range axis, generates just one ChartChangeEvent. */ @Test public void test2502355_restoreAutoRangeBounds() { DefaultXYDataset dataset = new DefaultXYDataset(); JFreeChart chart = ChartFactory.createXYLineChart("TestChart", "X", "Y", dataset, PlotOrientation.VERTICAL, false, false, false); XYPlot plot = (XYPlot) chart.getPlot(); plot.setRangeAxis(1, new NumberAxis("X2")); ChartPanel panel = new ChartPanel(chart); chart.addChangeListener(this); this.chartChangeEvents.clear(); panel.restoreAutoRangeBounds(); assertEquals(1, this.chartChangeEvents.size()); }
Example 14
Source File: ChartPanelTest.java From openstock with GNU General Public License v3.0 | 5 votes |
/** * Checks that a call to the zoomOutRange() method, for a plot with more * than one range axis, generates just one ChartChangeEvent. */ @Test public void test2502355_zoomOutRange() { DefaultXYDataset dataset = new DefaultXYDataset(); JFreeChart chart = ChartFactory.createXYLineChart("TestChart", "X", "Y", dataset, PlotOrientation.VERTICAL, false, false, false); XYPlot plot = (XYPlot) chart.getPlot(); plot.setRangeAxis(1, new NumberAxis("X2")); ChartPanel panel = new ChartPanel(chart); chart.addChangeListener(this); this.chartChangeEvents.clear(); panel.zoomOutRange(1.0, 2.0); assertEquals(1, this.chartChangeEvents.size()); }
Example 15
Source File: ChartPanelTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Checks that a call to the zoomInRange() method, for a plot with more * than one range axis, generates just one ChartChangeEvent. */ public void test2502355_zoomInRange() { DefaultXYDataset dataset = new DefaultXYDataset(); JFreeChart chart = ChartFactory.createXYLineChart("TestChart", "X", "Y", dataset, false); XYPlot plot = (XYPlot) chart.getPlot(); plot.setRangeAxis(1, new NumberAxis("X2")); ChartPanel panel = new ChartPanel(chart); chart.addChangeListener(this); this.chartChangeEvents.clear(); panel.zoomInRange(1.0, 2.0); assertEquals(1, this.chartChangeEvents.size()); }
Example 16
Source File: CombinedXYPlot.java From openstock with GNU General Public License v3.0 | 5 votes |
/** * Adds a new subplot with the specified weight. * * @param subplot the subplot. * @param weight the weight for the subplot. */ public void add(XYPlot subplot, int weight) { super.add(subplot, weight); ValueAxis l_range = super.getRangeAxis(); subplot.setRangeAxis(0, l_range, false); super.setRangeAxis(l_range); if (null == l_range) { return; } l_range.configure(); }
Example 17
Source File: Scatter.java From hortonmachine with GNU General Public License v3.0 | 4 votes |
public JFreeChart getChart() { if (chart == null) { chart = ChartFactory.createXYLineChart(title, // chart title xLabel, // domain axis label yLabel, // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips? false // URLs? ); XYPlot plot = (XYPlot) chart.getPlot(); if (xLog) { LogAxis xAxis = new LogAxis(""); xAxis.setBase(10); plot.setDomainAxis(xAxis); } if (yLog) { LogAxis yAxis = new LogAxis(""); yAxis.setBase(10); plot.setRangeAxis(yAxis); } if (colors == null) { colors = ColorBrewer.getPairedColors(dataset.getSeriesCount()); } for( int i = 0; i < colors.length; i++ ) { plot.getRenderer().setSeriesPaint(i, colors[i]); } ValueAxis rangeAxis = plot.getRangeAxis(); if (rangeAxis instanceof NumberAxis) { NumberAxis axis = (NumberAxis) rangeAxis; axis.setAutoRangeIncludesZero(false); } XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); double x = 1.5; double w = x * 2; renderer.setSeriesShape(0, new Ellipse2D.Double(-x, x, w, w)); setShapeLinesVisibility(plot); } return chart; }
Example 18
Source File: ChartJFreeChartOutputScatter.java From gama with GNU General Public License v3.0 | 4 votes |
@Override public void initChart(final IScope scope, final String chartname) { super.initChart(scope, chartname); final XYPlot pp = (XYPlot) chart.getPlot(); pp.setDomainGridlinePaint(axesColor); pp.setRangeGridlinePaint(axesColor); pp.setDomainCrosshairPaint(axesColor); pp.setRangeCrosshairPaint(axesColor); pp.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); pp.setDomainCrosshairVisible(false); pp.setRangeCrosshairVisible(false); pp.getDomainAxis().setAxisLinePaint(axesColor); pp.getDomainAxis().setTickLabelFont(getTickFont()); pp.getDomainAxis().setLabelFont(getLabelFont()); if (textColor != null) { pp.getDomainAxis().setLabelPaint(textColor); pp.getDomainAxis().setTickLabelPaint(textColor); } NumberAxis axis = (NumberAxis) pp.getRangeAxis(); axis = formatYAxis(scope, axis); pp.setRangeAxis(axis); if (ytickunit > 0) { ((NumberAxis) pp.getRangeAxis()).setTickUnit(new NumberTickUnit(ytickunit)); pp.setRangeGridlinesVisible(true); } else { pp.setRangeGridlinesVisible(GamaPreferences.Displays.CHART_GRIDLINES.getValue()); } // resetAutorange(scope); if (getType() == ChartOutput.SERIES_CHART) { if (xlabel == null) { xlabel = "time"; } } if (getType() == ChartOutput.XY_CHART) {} if (getType() == ChartOutput.SCATTER_CHART) {} if (!this.getXTickValueVisible(scope)) { pp.getDomainAxis().setTickMarksVisible(false); pp.getDomainAxis().setTickLabelsVisible(false); } }
Example 19
Source File: SWTMultipleAxisDemo1.java From openstock with GNU General Public License v3.0 | 4 votes |
/** * Creates the demo chart. * * @return The chart. */ private static JFreeChart createChart() { XYDataset dataset1 = createDataset("Series 1", 100.0, new Minute(), 200); JFreeChart chart = ChartFactory.createTimeSeriesChart( "Multiple Axis Demo 3", "Time of Day", "Primary Range Axis", dataset1, true, true, false ); chart.setBackgroundPaint(Color.white); chart.setBorderVisible(true); chart.setBorderPaint(Color.BLACK); TextTitle subtitle = new TextTitle("Four datasets and four range axes."); chart.addSubtitle(subtitle); XYPlot plot = (XYPlot) chart.getPlot(); plot.setOrientation(PlotOrientation.VERTICAL); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); XYItemRenderer renderer = plot.getRenderer(); renderer.setSeriesPaint(0, Color.black); // AXIS 2 NumberAxis axis2 = new NumberAxis("Range Axis 2"); axis2.setAutoRangeIncludesZero(false); axis2.setLabelPaint(Color.red); axis2.setTickLabelPaint(Color.red); plot.setRangeAxis(1, axis2); plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_LEFT); XYDataset dataset2 = createDataset("Series 2", 1000.0, new Minute(), 170); plot.setDataset(1, dataset2); plot.mapDatasetToRangeAxis(1, 1); XYItemRenderer renderer2 = new StandardXYItemRenderer(); renderer2.setSeriesPaint(0, Color.red); plot.setRenderer(1, renderer2); // AXIS 3 NumberAxis axis3 = new NumberAxis("Range Axis 3"); axis3.setLabelPaint(Color.blue); axis3.setTickLabelPaint(Color.blue); //axis3.setPositiveArrowVisible(true); plot.setRangeAxis(2, axis3); XYDataset dataset3 = createDataset("Series 3", 10000.0, new Minute(), 170); plot.setDataset(2, dataset3); plot.mapDatasetToRangeAxis(2, 2); XYItemRenderer renderer3 = new StandardXYItemRenderer(); renderer3.setSeriesPaint(0, Color.blue); plot.setRenderer(2, renderer3); // AXIS 4 NumberAxis axis4 = new NumberAxis("Range Axis 4"); axis4.setLabelPaint(Color.green); axis4.setTickLabelPaint(Color.green); plot.setRangeAxis(3, axis4); XYDataset dataset4 = createDataset("Series 4", 25.0, new Minute(), 200); plot.setDataset(3, dataset4); plot.mapDatasetToRangeAxis(3, 3); XYItemRenderer renderer4 = new StandardXYItemRenderer(); renderer4.setSeriesPaint(0, Color.green); plot.setRenderer(3, renderer4); return chart; }
Example 20
Source File: FrmElevationFilter.java From Course_Generator with GNU General Public License v3.0 | 4 votes |
/** * Update the chart * * @param dataset1 * @param dataset2 * @return */ private JFreeChart CreateChart(XYDataset dataset1, XYDataset dataset2) { JFreeChart chart = ChartFactory.createXYAreaChart("", // x axis label bundle.getString("frmElevationFilter.labelX"), // "Distance" // y axis label bundle.getString("frmElevationFilter.labelY1"), // "Elevation" dataset1, // data PlotOrientation.VERTICAL, false, // include legend true, // tooltips false // urls ); // -- Background color chart.setBackgroundPaint(Color.white); chart.setAntiAlias(true); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.gray); plot.setRangeGridlinePaint(Color.gray); plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); XYAreaRenderer renderer = new XYAreaRenderer(); renderer.setSeriesPaint(0, new Color(0x99, 0xff, 0x00)); renderer.setOutline(true); renderer.setSeriesOutlineStroke(0, new BasicStroke(2.0f)); plot.setRenderer(0, renderer); NumberAxis rangeAxis2 = new NumberAxis("");// bundle.getString("JPanelAnalysisTimeDist.labelY2")); // "Time" // plot.setRangeAxis(1, rangeAxis2); plot.setDataset(1, dataset2); plot.setRangeAxis(1, rangeAxis2); // plot.mapDatasetToRangeAxis(1, 1); StandardXYItemRenderer renderer2 = new StandardXYItemRenderer(); renderer2.setSeriesPaint(0, Color.red); renderer2.setSeriesStroke(0, new BasicStroke(1.0f)); plot.setRenderer(1, renderer2); // -- Select the display order plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); return chart; }