Java Code Examples for org.jfree.chart.plot.XYPlot#setAxisOffset()
The following examples show how to use
org.jfree.chart.plot.XYPlot#setAxisOffset() .
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: Grafico.java From cst with GNU Lesser General Public License v3.0 | 6 votes |
public Grafico(String frametitle, String charttitle, String xlabel, String ylabel, XYSeriesCollection dataset){ JFreeChart chart = ChartFactory.createXYLineChart(charttitle, xlabel, ylabel, dataset, PlotOrientation.VERTICAL, true, true, false); 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.setShapesVisible(true); renderer.setShapesFilled(true); setXyplot(plot); setChart(chart); ChartFrame frame= new ChartFrame(frametitle,chart); frame.pack(); frame.setVisible(true); }
Example 2
Source File: ChartWriter.java From kurento-java with Apache License 2.0 | 6 votes |
public void drawChart(String filename, int width, int height) throws IOException { // Create plot NumberAxis xAxis = new NumberAxis(xAxisLabel); NumberAxis yAxis = new NumberAxis(yAxisLabel); XYSplineRenderer renderer = new XYSplineRenderer(); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(4, 4, 4, 4)); // Create chart JFreeChart chart = new JFreeChart(chartTitle, JFreeChart.DEFAULT_TITLE_FONT, plot, true); ChartUtilities.applyCurrentTheme(chart); ChartPanel chartPanel = new ChartPanel(chart, false); // Draw png BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_BGR); Graphics graphics = bi.getGraphics(); chartPanel.setBounds(0, 0, width, height); chartPanel.paint(graphics); ImageIO.write(bi, "png", new File(filename)); }
Example 3
Source File: AbstractChartsPanel.java From computational-economy with GNU General Public License v3.0 | 6 votes |
protected void configureChart(final JFreeChart chart) { chart.setBackgroundPaint(Color.white); final XYPlot plot = (XYPlot) chart.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)); final DateAxis dateAxis = (DateAxis) plot.getDomainAxis(); final NumberAxis valueAxis = (NumberAxis) plot.getRangeAxis(); dateAxis.setDateFormatOverride(new SimpleDateFormat("dd-MMM")); valueAxis.setAutoRangeIncludesZero(true); valueAxis.setUpperMargin(0.15); valueAxis.setLowerMargin(0.15); }
Example 4
Source File: StatisticsPanel.java From snap-desktop with GNU General Public License v3.0 | 5 votes |
private static ChartPanel getHistogramPlotPanel(XIntervalSeriesCollection dataset, String xAxisLabel, String yAxisLabel, Color color) { JFreeChart chart = ChartFactory.createHistogram( null, xAxisLabel, yAxisLabel, dataset, PlotOrientation.VERTICAL, false, // Legend? true, // tooltips false // url ); final XYPlot xyPlot = chart.getXYPlot(); //xyPlot.setForegroundAlpha(0.85f); xyPlot.setNoDataMessage("No data"); xyPlot.setAxisOffset(new RectangleInsets(5, 5, 5, 5)); final XYBarRenderer renderer = (XYBarRenderer) xyPlot.getRenderer(); renderer.setDrawBarOutline(false); renderer.setShadowVisible(false); renderer.setSeriesPaint(0, color); StandardXYBarPainter painter = new StandardXYBarPainter(); renderer.setBarPainter(painter); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new Dimension(300, 200)); // chartPanel.getPopupMenu().add(createCopyDataToClipboardMenuItem()); return chartPanel; }
Example 5
Source File: SWTTimeSeriesDemo.java From openstock with GNU General Public License v3.0 | 5 votes |
/** * Creates a chart. * * @param dataset a dataset. * * @return A chart. */ private static JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart( "Legal & General Unit Trust Prices", // title "Date", // x-axis label "Price Per Unit", // y-axis label dataset, // data true, // create legend? true, // generate tooltips? false // generate URLs? ); chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.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); } DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); return chart; }
Example 6
Source File: SWTTimeSeriesDemo.java From ECG-Viewer with GNU General Public License v2.0 | 5 votes |
/** * Creates a chart. * * @param dataset a dataset. * * @return A chart. */ private static JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart( "Legal & General Unit Trust Prices", // title "Date", // x-axis label "Price Per Unit", // y-axis label dataset, // data true, // create legend? true, // generate tooltips? false // generate URLs? ); chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.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); } DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); return chart; }
Example 7
Source File: TimeSeriesChartDemo1.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
/** * Creates a chart. * * @param dataset a dataset. * * @return A chart. */ private static JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart( "Legal & General Unit Trust Prices", // title "Date", // x-axis label "Price Per Unit", // y-axis label dataset, // data true, // create legend? true, // generate tooltips? false // generate URLs? ); chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.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")); return chart; }
Example 8
Source File: HistogramPanel.java From snap-desktop with GNU General Public License v3.0 | 5 votes |
private ChartPanel createChartPanel(JFreeChart chart) { XYPlot plot = chart.getXYPlot(); plot.setForegroundAlpha(0.85f); plot.setNoDataMessage(NO_DATA_MESSAGE); plot.setAxisOffset(new RectangleInsets(5, 5, 5, 5)); ChartPanel chartPanel = new ChartPanel(chart); MaskSelectionToolSupport maskSelectionToolSupport = new MaskSelectionToolSupport(this, chartPanel, "histogram_plot_area", "Mask generated from selected histogram plot area", Color.RED, PlotAreaSelectionTool.AreaType.X_RANGE) { @Override protected String createMaskExpression(PlotAreaSelectionTool.AreaType areaType, Shape shape) { Rectangle2D bounds = shape.getBounds2D(); return createMaskExpression(bounds.getMinX(), bounds.getMaxX()); } protected String createMaskExpression(double x1, double x2) { String bandName = BandArithmetic.createExternalName(getRaster().getName()); HistogramPanelModel.HistogramConfig currentConfig = createHistogramConfig(); return String.format("%s >= %s && %s <= %s", bandName, model.hasStx(currentConfig) ? model.getStx(currentConfig).getHistogramScaling().scaleInverse(x1) : x1, bandName, model.hasStx(currentConfig) ? model.getStx(currentConfig).getHistogramScaling().scaleInverse(x2) : x2); } }; chartPanel.getPopupMenu().addSeparator(); chartPanel.getPopupMenu().add(maskSelectionToolSupport.createMaskSelectionModeMenuItem()); chartPanel.getPopupMenu().add(maskSelectionToolSupport.createDeleteMaskMenuItem()); chartPanel.getPopupMenu().addSeparator(); chartPanel.getPopupMenu().add(createCopyDataToClipboardMenuItem()); return chartPanel; }
Example 9
Source File: SWTTimeSeriesDemo.java From ccu-historian with GNU General Public License v3.0 | 5 votes |
/** * Creates a chart. * * @param dataset a dataset. * * @return A chart. */ private static JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart( "Legal & General Unit Trust Prices", // title "Date", // x-axis label "Price Per Unit", // y-axis label dataset, // data true, // create legend? true, // generate tooltips? false // generate URLs? ); chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.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); } DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); return chart; }
Example 10
Source File: TimeSeriesChartDemo1.java From ccu-historian with GNU General Public License v3.0 | 5 votes |
/** * Creates a chart. * * @param dataset a dataset. * * @return A chart. */ private static JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart( "Legal & General Unit Trust Prices", // title "Date", // x-axis label "Price Per Unit", // y-axis label dataset, // data true, // create legend? true, // generate tooltips? false // generate URLs? ); chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.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")); return chart; }
Example 11
Source File: DSWorkbenchStatsFrame.java From dsworkbench with Apache License 2.0 | 5 votes |
private void setupPlotDrawing(XYPlot pPlot) { pPlot.setBackgroundPaint(Constants.DS_BACK_LIGHT); pPlot.setDomainGridlinePaint(Color.DARK_GRAY); pPlot.setRangeGridlinePaint(Color.DARK_GRAY); pPlot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); pPlot.setDomainCrosshairVisible(true); pPlot.setRangeCrosshairVisible(true); DateAxis axis = (DateAxis) pPlot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("dd.MM.yyyy HH:mm:ss")); }
Example 12
Source File: TimeSeriesChartDemo1.java From opensim-gui with Apache License 2.0 | 5 votes |
/** * Creates a chart. * * @param dataset a dataset. * * @return A chart. */ private static JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart( "Legal & General Unit Trust Prices", // title "Date", // x-axis label "Price Per Unit", // y-axis label dataset, // data true, // create legend? true, // generate tooltips? false // generate URLs? ); chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.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); } DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); return chart; }
Example 13
Source File: TimeSeriesChartDemo1.java From ECG-Viewer with GNU General Public License v2.0 | 5 votes |
/** * Creates a chart. * * @param dataset a dataset. * * @return A chart. */ private static JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart( "Legal & General Unit Trust Prices", // title "Date", // x-axis label "Price Per Unit", // y-axis label dataset, // data true, // create legend? true, // generate tooltips? false // generate URLs? ); chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.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")); return chart; }
Example 14
Source File: SWTMultipleAxisDemo1.java From astor with GNU General Public License v2.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)); plot.getRangeAxis().setFixedDimension(15.0); XYItemRenderer renderer = plot.getRenderer(); renderer.setSeriesPaint(0, Color.black); // AXIS 2 NumberAxis axis2 = new NumberAxis("Range Axis 2"); axis2.setFixedDimension(10.0); 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 15
Source File: SWTMultipleAxisDemo1.java From ECG-Viewer with GNU General Public License v2.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 16
Source File: SpectrumChartFactory.java From mzmine2 with GNU General Public License v2.0 | 4 votes |
public static JFreeChart createChart(PseudoSpectrumDataSet dataset, boolean showTitle, boolean showLegend, double rt, double precursorMZ) { // if (dataset == null) return null; // NumberFormat mzForm = MZmineCore.getConfiguration().getMZFormat(); NumberFormat rtForm = MZmineCore.getConfiguration().getRTFormat(); NumberFormat intensityFormat = MZmineCore.getConfiguration().getIntensityFormat(); String title = ""; if (precursorMZ == 0) title = "RT=" + mzForm.format(precursorMZ); else title = MessageFormat.format("MSMS for m/z={0} RT={1}", mzForm.format(precursorMZ), rtForm.format(rt)); JFreeChart chart = ChartFactory.createXYLineChart(title, // title "m/z", // x-axis label "Intensity", // y-axis label dataset, // data set PlotOrientation.VERTICAL, // orientation true, // isotopeFlag, // create legend? true, // generate tooltips? false // generate URLs? ); chart.setBackgroundPaint(Color.white); chart.getTitle().setVisible(false); // set the plot properties XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setAxisOffset(RectangleInsets.ZERO_INSETS); // set rendering order plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); // set crosshair (selection) properties plot.setDomainCrosshairVisible(false); plot.setRangeCrosshairVisible(false); // set the X axis (retention time) properties NumberAxis xAxis = (NumberAxis) plot.getDomainAxis(); xAxis.setNumberFormatOverride(mzForm); xAxis.setUpperMargin(0.08); xAxis.setLowerMargin(0.00); xAxis.setTickLabelInsets(new RectangleInsets(0, 0, 20, 20)); xAxis.setAutoRangeIncludesZero(true); xAxis.setMinorTickCount(5); // set the Y axis (intensity) properties NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); yAxis.setNumberFormatOverride(intensityFormat); yAxis.setUpperMargin(0.20); PseudoSpectraRenderer renderer = new PseudoSpectraRenderer(Color.BLACK, false); plot.setRenderer(0, renderer); plot.setRenderer(1, renderer); plot.setRenderer(2, renderer); renderer.setSeriesVisibleInLegend(1, false); renderer.setSeriesPaint(2, Color.ORANGE); // chart.getTitle().setVisible(showTitle); chart.getLegend().setVisible(showLegend); // if (precursorMZ != 0) addPrecursorMarker(chart, precursorMZ); return chart; }
Example 17
Source File: ScatterPlotPanel.java From snap-desktop with GNU General Public License v3.0 | 4 votes |
private void createUI() { final XYPlot plot = getPlot(); plot.setAxisOffset(new RectangleInsets(5, 5, 5, 5)); plot.setNoDataMessage(NO_DATA_MESSAGE); int confidenceDSIndex = 0; int regressionDSIndex = 1; int scatterpointsDSIndex = 2; plot.setDataset(confidenceDSIndex, acceptableDeviationDataset); plot.setDataset(regressionDSIndex, regressionDataset); plot.setDataset(scatterpointsDSIndex, scatterpointsDataset); plot.addAnnotation(r2Annotation); final DeviationRenderer identityRenderer = new DeviationRenderer(true, false); identityRenderer.setSeriesPaint(0, StatisticChartStyling.SAMPLE_DATA_PAINT); identityRenderer.setSeriesFillPaint(0, StatisticChartStyling.SAMPLE_DATA_FILL_PAINT); plot.setRenderer(confidenceDSIndex, identityRenderer); final DeviationRenderer regressionRenderer = new DeviationRenderer(true, false); regressionRenderer.setSeriesPaint(0, StatisticChartStyling.REGRESSION_DATA_PAINT); regressionRenderer.setSeriesFillPaint(0, StatisticChartStyling.REGRESSION_DATA_FILL_PAINT); plot.setRenderer(regressionDSIndex, regressionRenderer); final XYErrorRenderer scatterPointsRenderer = new XYErrorRenderer(); scatterPointsRenderer.setDrawXError(true); scatterPointsRenderer.setErrorStroke(new BasicStroke(1)); scatterPointsRenderer.setErrorPaint(StatisticChartStyling.CORRELATIVE_POINT_OUTLINE_PAINT); scatterPointsRenderer.setSeriesShape(0, StatisticChartStyling.CORRELATIVE_POINT_SHAPE); scatterPointsRenderer.setSeriesOutlinePaint(0, StatisticChartStyling.CORRELATIVE_POINT_OUTLINE_PAINT); scatterPointsRenderer.setSeriesFillPaint(0, StatisticChartStyling.CORRELATIVE_POINT_FILL_PAINT); scatterPointsRenderer.setSeriesLinesVisible(0, false); scatterPointsRenderer.setSeriesShapesVisible(0, true); scatterPointsRenderer.setSeriesOutlineStroke(0, new BasicStroke(1.0f)); scatterPointsRenderer.setSeriesToolTipGenerator(0, (dataset, series, item) -> { final XYIntervalSeriesCollection collection = (XYIntervalSeriesCollection) dataset; final Comparable key = collection.getSeriesKey(series); final double xValue = collection.getXValue(series, item); final double endYValue = collection.getEndYValue(series, item); final double yValue = collection.getYValue(series, item); return String.format("%s: mean = %6.2f, sigma = %6.2f | %s: value = %6.2f", getRasterName(), yValue, endYValue - yValue, key, xValue); }); plot.setRenderer(scatterpointsDSIndex, scatterPointsRenderer); final boolean autoRangeIncludesZero = false; final boolean xLog = scatterPlotModel.xAxisLogScaled; final boolean yLog = scatterPlotModel.yAxisLogScaled; plot.setDomainAxis( StatisticChartStyling.updateScalingOfAxis(xLog, plot.getDomainAxis(), autoRangeIncludesZero)); plot.setRangeAxis(StatisticChartStyling.updateScalingOfAxis(yLog, plot.getRangeAxis(), autoRangeIncludesZero)); createUI(createChartPanel(chart), createInputParameterPanel(), bindingContext); plot.getDomainAxis().addChangeListener(domainAxisChangeListener); scatterPlotDisplay.setMouseWheelEnabled(true); scatterPlotDisplay.setMouseZoomable(true); }
Example 18
Source File: SWTMultipleAxisDemo1.java From SIMVA-SoS with Apache License 2.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 19
Source File: TimeSeriesChartDemo1.java From astor with GNU General Public License v2.0 | 4 votes |
/** * Creates a chart. * * @param dataset a dataset. * * @return A chart. */ private static JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart( "Legal & General Unit Trust Prices", // title "Date", // x-axis label "Price Per Unit", // y-axis label dataset, // data true, // create legend? true, // generate tooltips? false // generate URLs? ); chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.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); } DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); return chart; }
Example 20
Source File: PlotUtil.java From dl4j-tutorials with MIT License | 4 votes |
private static JFreeChart createChart(XYZDataset dataset, double[] mins, double[] maxs, int nPoints, XYDataset xyData) { NumberAxis xAxis = new NumberAxis("X"); xAxis.setRange(mins[0],maxs[0]); NumberAxis yAxis = new NumberAxis("Y"); yAxis.setRange(mins[1], maxs[1]); XYBlockRenderer renderer = new XYBlockRenderer(); renderer.setBlockWidth((maxs[0]-mins[0])/(nPoints-1)); renderer.setBlockHeight((maxs[1] - mins[1]) / (nPoints - 1)); PaintScale scale = new GrayPaintScale(0, 1.0); renderer.setPaintScale(scale); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinesVisible(false); plot.setRangeGridlinesVisible(false); plot.setAxisOffset(new RectangleInsets(5, 5, 5, 5)); JFreeChart chart = new JFreeChart("", plot); chart.getXYPlot().getRenderer().setSeriesVisibleInLegend(0, false); NumberAxis scaleAxis = new NumberAxis("Probability (class 0)"); scaleAxis.setAxisLinePaint(Color.white); scaleAxis.setTickMarkPaint(Color.white); scaleAxis.setTickLabelFont(new Font("Dialog", Font.PLAIN, 7)); PaintScaleLegend legend = new PaintScaleLegend(new GrayPaintScale(), scaleAxis); legend.setStripOutlineVisible(false); legend.setSubdivisionCount(20); legend.setAxisLocation(AxisLocation.BOTTOM_OR_LEFT); legend.setAxisOffset(5.0); legend.setMargin(new RectangleInsets(5, 5, 5, 5)); legend.setFrame(new BlockBorder(Color.red)); legend.setPadding(new RectangleInsets(10, 10, 10, 10)); legend.setStripWidth(10); legend.setPosition(RectangleEdge.LEFT); chart.addSubtitle(legend); ChartUtilities.applyCurrentTheme(chart); plot.setDataset(1, xyData); XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer(); renderer2.setBaseLinesVisible(false); plot.setRenderer(1, renderer2); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); return chart; }