List of usage examples for org.jfree.chart.renderer.xy XYErrorRenderer setSeriesLinesVisible
public void setSeriesLinesVisible(int series, Boolean flag)
From source file:projects.wdlf47tuc.ProcessAllSwathcal.java
/** * Computes the luminosity function for the current boxed region and plots it in a JFrame. * Also prints out the coordinates of the selection box vertices and the luminosity function * quantities./* ww w . j a v a2s. c o m*/ * * @param sources * The {@link Source}s to compute the luminosity function for. */ private void computeAndPlotLuminosityFunction(List<Source> sources) { // Print out coordinates of selection box corners System.out.println("# Coordinates of selection box corners:"); System.out.println("# (" + col1Filter + "-" + col2Filter + ")\t" + magFilter); for (double[] point : points) { System.out.println("# " + point[0] + "\t" + point[1]); } System.out.println("# Luminosity function:"); System.out.println("# Mag.\tN\tsigN"); double magBinWidth = 0.5; // Get the range of the data double mMin = Double.MAX_VALUE; double mMax = -Double.MAX_VALUE; for (Source source : sources) { double mag = source.getMag(magFilter) - mu; mMin = Math.min(mMin, mag); mMax = Math.max(mMax, mag); } // Quantize this to a whole number mMin = Math.floor(mMin); mMax = Math.ceil(mMax); int nBins = (int) Math.rint((mMax - mMin) / magBinWidth); // Array to accumulate all objects in each bin int[] n = new int[nBins]; for (Source source : sources) { double mag = source.getMag(magFilter) - mu; // Bin number int bin = (int) Math.floor((mag - mMin) / magBinWidth); n[bin]++; } YIntervalSeries luminosityFunction = new YIntervalSeries("Luminosity Function"); for (int i = 0; i < nBins; i++) { // Bin centre double x = mMin + i * magBinWidth + 0.5 * magBinWidth; double y = n[i]; double yErr = n[i] > 0 ? Math.sqrt(y) : 0; luminosityFunction.add(x, y, y - yErr, y + yErr); System.out.println(x + "\t" + y + "\t" + yErr); } final YIntervalSeriesCollection data = new YIntervalSeriesCollection(); data.addSeries(luminosityFunction); XYErrorRenderer renderer = new XYErrorRenderer(); renderer.setSeriesLinesVisible(0, true); renderer.setSeriesShapesVisible(0, true); renderer.setSeriesShape(0, new Ellipse2D.Float(-1f, -1f, 2, 2)); renderer.setSeriesPaint(0, ChartColor.BLACK); NumberAxis xAxis = new NumberAxis("Absolute Magnitude (" + magFilter.toString() + ")"); xAxis.setAutoRange(true); xAxis.setAutoRangeIncludesZero(false); NumberAxis yAxis = new NumberAxis("N"); yAxis.setAutoRange(true); yAxis.setAutoRangeIncludesZero(true); // Configure plot XYPlot xyplot = new XYPlot(data, xAxis, yAxis, renderer); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setDomainGridlinesVisible(true); xyplot.setRangeGridlinePaint(Color.white); // Configure chart JFreeChart chart = new JFreeChart("Luminosity Function", xyplot); chart.setBackgroundPaint(Color.white); chart.setTitle("47 Tuc luminosity function"); chart.removeLegend(); final ChartPanel lfChartPanel = new ChartPanel(chart); java.awt.EventQueue.invokeLater(new Runnable() { @Override public void run() { JFrame tester = new JFrame(); tester.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); tester.setLayout(new BorderLayout()); tester.add(lfChartPanel, BorderLayout.CENTER); tester.pack(); tester.setVisible(true); } }); }
From source file:org.esa.snap.rcp.statistics.ScatterPlotPanel.java
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); });/*from w ww . ja v a 2 s.c om*/ 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); }
From source file:org.esa.beam.visat.toolviews.stat.ScatterPlotPanel.java
private void createUI() { final XYPlot plot = getPlot(); plot.setAxisOffset(new RectangleInsets(5, 5, 5, 5)); plot.setNoDataMessage(NO_DATA_MESSAGE); plot.setDataset(CONFIDENCE_DSINDEX, acceptableDeviationDataset); plot.setDataset(REGRESSION_DSINDEX, regressionDataset); plot.setDataset(SCATTERPOINTS_DSINDEX, 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(CONFIDENCE_DSINDEX, 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(REGRESSION_DSINDEX, 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, new XYToolTipGenerator() { @Override//from w w w . jav a 2 s. c o m public String generateToolTip(XYDataset dataset, int series, int 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(SCATTERPOINTS_DSINDEX, 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); }