Example usage for org.jfree.data.xy XYSeries getMinX

List of usage examples for org.jfree.data.xy XYSeries getMinX

Introduction

In this page you can find the example usage for org.jfree.data.xy XYSeries getMinX.

Prototype

public double getMinX() 

Source Link

Document

Returns the smallest x-value in the series, ignoring any Double.NaN values.

Usage

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 .ja v  a 2s.c  om*/
    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:com.ivli.roim.controls.DomainMarker.java

public DomainMarker(XYSeries aSet) {
    this((aSet.getMaxX() - aSet.getMinX()) / 2., aSet);
}

From source file:edu.ucsf.valelab.spotintensityanalysis.plot.PlotUtils.java

/**
 * Create a frame with a plot of the data given in XYSeries overwrite any
 * previously created frame with the same title
 *
        /*from  ww w . j a  v a2 s.c  o  m*/
 * @param title shown in the top of the plot
 * @param data array with data series to be plotted
 * @param xTitle Title of the X axis
 * @param yTitle Title of the Y axis
 * @param showShapes whether or not to draw shapes at the data points
 * @param annotation to be shown in plot
 * @return Frame that displays the data
 */
public Frame plotDataN(String title, XYSeries[] data, String xTitle, String yTitle, boolean[] showShapes,
        String annotation) {

    // JFreeChart code
    XYSeriesCollection dataset = new XYSeriesCollection();
    // calculate min and max to scale the graph
    double minX, minY, maxX, maxY;
    minX = data[0].getMinX();
    minY = data[0].getMinY();
    maxX = data[0].getMaxX();
    maxY = data[0].getMaxY();
    for (XYSeries d : data) {
        dataset.addSeries(d);
        if (d.getMinX() < minX) {
            minX = d.getMinX();
        }
        if (d.getMaxX() > maxX) {
            maxX = d.getMaxX();
        }
        if (d.getMinY() < minY) {
            minY = d.getMinY();
        }
        if (d.getMaxY() > maxY) {
            maxY = d.getMaxY();
        }
    }

    JFreeChart chart = ChartFactory.createScatterPlot(title, // Title
            xTitle, // x-axis Label
            yTitle, // 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();
    plot.setBackgroundPaint(Color.white);
    plot.setRangeGridlinePaint(Color.lightGray);

    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setBaseShapesVisible(true);

    for (int i = 0; i < data.length; i++) {
        renderer.setSeriesFillPaint(i, Color.white);
        renderer.setSeriesLinesVisible(i, true);
    }

    renderer.setSeriesPaint(0, Color.blue);
    Shape circle = new Ellipse2D.Float(-2.0f, -2.0f, 4.0f, 4.0f);
    renderer.setSeriesShape(0, circle, false);

    if (data.length > 1) {
        renderer.setSeriesPaint(1, Color.red);
        Shape square = new Rectangle2D.Float(-2.0f, -2.0f, 4.0f, 4.0f);
        renderer.setSeriesShape(1, square, false);
    }
    if (data.length > 2) {
        renderer.setSeriesPaint(2, Color.darkGray);
        Shape rect = new Rectangle2D.Float(-2.0f, -1.0f, 4.0f, 2.0f);
        renderer.setSeriesShape(2, rect, false);
    }
    if (data.length > 3) {
        renderer.setSeriesPaint(3, Color.magenta);
        Shape rect = new Rectangle2D.Float(-1.0f, -2.0f, 2.0f, 4.0f);
        renderer.setSeriesShape(3, rect, false);
    }

    for (int i = 0; i < data.length; i++) {
        if (showShapes.length > i && !showShapes[i]) {
            renderer.setSeriesShapesVisible(i, false);
        }
    }

    // place annotation at 80 % of max X, maxY
    XYAnnotation an = new XYTextAnnotation(annotation, maxX - 0.2 * (maxX - minX), maxY);
    plot.addAnnotation(an);

    renderer.setUseFillPaint(true);

    if (graphFrame_ == null)
        graphFrame_ = new MyChartFrame(title, chart);
    else
        graphFrame_.getChartPanel().setChart(chart);
    graphFrame_.getChartPanel().setMouseWheelEnabled(true);
    graphFrame_.pack();
    final MyChartFrame privateFrame = graphFrame_;
    graphFrame_.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent arg0) {
            privateFrame.dispose();
        }
    });

    graphFrame_.setVisible(true);

    return graphFrame_;
}

From source file:edu.ucsf.valelab.saim.plot.PlotUtils.java

/**
 * Create a frame with a plot of the data given in XYSeries overwrite any
 * previously created frame with the same title
 *
        /*from ww w  .j  a  v a2  s.com*/
 * @param title shown in the top of the plot
 * @param data array with data series to be plotted
 * @param xTitle Title of the X axis
 * @param yTitle Title of the Y axis
 * @param showShapes whether or not to draw shapes at the data points
 * @param annotation to be shown in plot
 * @return Frame that displays the data
 */
public Frame plotDataN(String title, XYSeries[] data, String xTitle, String yTitle, boolean[] showShapes,
        String annotation) {

    // Close existing frames
    // Frame[] gfs = ChartFrame.getFrames();
    // for (Frame f : gfs) {
    //if (f.getTitle().equals(title)) {
    //   f.dispose();
    //}
    // }

    // JFreeChart code
    XYSeriesCollection dataset = new XYSeriesCollection();
    // calculate min and max to scale the graph
    double minX, minY, maxX, maxY;
    minX = data[0].getMinX();
    minY = data[0].getMinY();
    maxX = data[0].getMaxX();
    maxY = data[0].getMaxY();
    for (XYSeries d : data) {
        dataset.addSeries(d);
        if (d.getMinX() < minX) {
            minX = d.getMinX();
        }
        if (d.getMaxX() > maxX) {
            maxX = d.getMaxX();
        }
        if (d.getMinY() < minY) {
            minY = d.getMinY();
        }
        if (d.getMaxY() > maxY) {
            maxY = d.getMaxY();
        }
    }

    JFreeChart chart = ChartFactory.createScatterPlot(title, // Title
            xTitle, // x-axis Label
            yTitle, // 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();
    plot.setBackgroundPaint(Color.white);
    plot.setRangeGridlinePaint(Color.lightGray);

    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setBaseShapesVisible(true);

    for (int i = 0; i < data.length; i++) {
        renderer.setSeriesFillPaint(i, Color.white);
        renderer.setSeriesLinesVisible(i, true);
    }

    renderer.setSeriesPaint(0, Color.blue);
    Shape circle = new Ellipse2D.Float(-2.0f, -2.0f, 4.0f, 4.0f);
    renderer.setSeriesShape(0, circle, false);

    if (data.length > 1) {
        renderer.setSeriesPaint(1, Color.red);
        Shape square = new Rectangle2D.Float(-2.0f, -2.0f, 4.0f, 4.0f);
        renderer.setSeriesShape(1, square, false);
    }
    if (data.length > 2) {
        renderer.setSeriesPaint(2, Color.darkGray);
        Shape rect = new Rectangle2D.Float(-2.0f, -1.0f, 4.0f, 2.0f);
        renderer.setSeriesShape(2, rect, false);
    }
    if (data.length > 3) {
        renderer.setSeriesPaint(3, Color.magenta);
        Shape rect = new Rectangle2D.Float(-1.0f, -2.0f, 2.0f, 4.0f);
        renderer.setSeriesShape(3, rect, false);
    }

    for (int i = 0; i < data.length; i++) {
        if (showShapes.length > i && !showShapes[i]) {
            renderer.setSeriesShapesVisible(i, false);
        }
    }

    // place annotation at 80 % of max X, maxY
    XYAnnotation an = new XYTextAnnotation(annotation, maxX - 0.2 * (maxX - minX), maxY);
    plot.addAnnotation(an);

    renderer.setUseFillPaint(true);

    final MyChartFrame graphFrame = new MyChartFrame(title, chart);
    graphFrame.getChartPanel().setMouseWheelEnabled(true);
    graphFrame.pack();
    graphFrame.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent arg0) {
            graphFrame.dispose();
        }
    });

    graphFrame.setVisible(true);

    return graphFrame;
}

From source file:org.micromanager.saim.plot.PlotUtils.java

/**
 * Create a frame with a plot of the data given in XYSeries overwrite any
 * previously created frame with the same title
 *
        //  ww w.  ja v  a  2s .  c o  m
 * @param title shown in the top of the plot
 * @param data array with data series to be plotted
 * @param xTitle Title of the X axis
 * @param yTitle Title of the Y axis
 * @param showShapes whether or not to draw shapes at the data points
 * @param annotation to be shown in plot
 * @return Frame that displays the data
 */
public Frame plotDataN(String title, XYSeries[] data, String xTitle, String yTitle, boolean[] showShapes,
        String annotation) {

    //Close existing frames
    Frame[] gfs = ChartFrame.getFrames();
    for (Frame f : gfs) {
        if (f.getTitle().equals(title)) {
            f.dispose();
        }
    }

    // JFreeChart code
    XYSeriesCollection dataset = new XYSeriesCollection();
    // calculate min and max to scale the graph
    double minX, minY, maxX, maxY;
    minX = data[0].getMinX();
    minY = data[0].getMinY();
    maxX = data[0].getMaxX();
    maxY = data[0].getMaxY();
    for (XYSeries d : data) {
        dataset.addSeries(d);
        if (d.getMinX() < minX) {
            minX = d.getMinX();
        }
        if (d.getMaxX() > maxX) {
            maxX = d.getMaxX();
        }
        if (d.getMinY() < minY) {
            minY = d.getMinY();
        }
        if (d.getMaxY() > maxY) {
            maxY = d.getMaxY();
        }
    }

    JFreeChart chart = ChartFactory.createScatterPlot(title, // Title
            xTitle, // x-axis Label
            yTitle, // 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();
    plot.setBackgroundPaint(Color.white);
    plot.setRangeGridlinePaint(Color.lightGray);

    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setBaseShapesVisible(true);

    for (int i = 0; i < data.length; i++) {
        renderer.setSeriesFillPaint(i, Color.white);
        renderer.setSeriesLinesVisible(i, true);
    }

    renderer.setSeriesPaint(0, Color.blue);
    Shape circle = new Ellipse2D.Float(-2.0f, -2.0f, 4.0f, 4.0f);
    renderer.setSeriesShape(0, circle, false);

    if (data.length > 1) {
        renderer.setSeriesPaint(1, Color.red);
        Shape square = new Rectangle2D.Float(-2.0f, -2.0f, 4.0f, 4.0f);
        renderer.setSeriesShape(1, square, false);
    }
    if (data.length > 2) {
        renderer.setSeriesPaint(2, Color.darkGray);
        Shape rect = new Rectangle2D.Float(-2.0f, -1.0f, 4.0f, 2.0f);
        renderer.setSeriesShape(2, rect, false);
    }
    if (data.length > 3) {
        renderer.setSeriesPaint(3, Color.magenta);
        Shape rect = new Rectangle2D.Float(-1.0f, -2.0f, 2.0f, 4.0f);
        renderer.setSeriesShape(3, rect, false);
    }

    for (int i = 0; i < data.length; i++) {
        if (showShapes.length > i && !showShapes[i]) {
            renderer.setSeriesShapesVisible(i, false);
        }
    }

    // place annotation at 80 % of max X, maxY
    XYAnnotation an = new XYTextAnnotation(annotation, maxX - 0.2 * (maxX - minX), maxY);
    plot.addAnnotation(an);

    renderer.setUseFillPaint(true);

    final MyChartFrame graphFrame = new MyChartFrame(title, chart);
    graphFrame.getChartPanel().setMouseWheelEnabled(true);
    graphFrame.pack();
    graphFrame.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent arg0) {
            graphFrame.dispose();
        }
    });

    graphFrame.setVisible(true);

    return graphFrame;
}

From source file:org.micromanager.asidispim.Utils.PlotUtils.java

/**
 * Create a frame with a plot of the data given in XYSeries overwrite any
 * previously created frame with the same title
 *
        /*from w w w  . ja va 2s .  c  o  m*/
 * @param title shown in the top of the plot
 * @param data array with data series to be plotted
 * @param xTitle Title of the X axis
 * @param yTitle Title of the Y axis
 * @param showShapes whether or not to draw shapes at the data points
 * @param annotation to be shown in plot
 * @return Frame that displays the data
 */
public Frame plotDataN(String title, XYSeries[] data, String xTitle, String yTitle, boolean[] showShapes,
        String annotation) {

    // if we already have a plot open with this title, close it, but remember
    // its position
    Frame[] gfs = ChartFrame.getFrames();
    for (Frame f : gfs) {
        if (f.getTitle().equals(title)) {
            f.dispose();
        }
    }

    // JFreeChart code
    XYSeriesCollection dataset = new XYSeriesCollection();
    // calculate min and max to scale the graph
    double minX, minY, maxX, maxY;
    minX = data[0].getMinX();
    minY = data[0].getMinY();
    maxX = data[0].getMaxX();
    maxY = data[0].getMaxY();
    for (XYSeries d : data) {
        dataset.addSeries(d);
        if (d.getMinX() < minX) {
            minX = d.getMinX();
        }
        if (d.getMaxX() > maxX) {
            maxX = d.getMaxX();
        }
        if (d.getMinY() < minY) {
            minY = d.getMinY();
        }
        if (d.getMaxY() > maxY) {
            maxY = d.getMaxY();
        }
    }

    JFreeChart chart = ChartFactory.createScatterPlot(title, // Title
            xTitle, // x-axis Label
            yTitle, // y-axis Label
            dataset, // Dataset
            PlotOrientation.VERTICAL, // Plot Orientation
            false, // Show Legend
            true, // Use tooltips
            false // Configure chart to generate URLs?
    );
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setRangeGridlinePaint(Color.lightGray);

    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setBaseShapesVisible(true);

    for (int i = 0; i < data.length; i++) {
        renderer.setSeriesFillPaint(i, Color.white);
        renderer.setSeriesLinesVisible(i, true);
    }

    renderer.setSeriesPaint(0, Color.blue);
    Shape circle = new Ellipse2D.Float(-2.0f, -2.0f, 4.0f, 4.0f);
    renderer.setSeriesShape(0, circle, false);

    if (data.length > 1) {
        renderer.setSeriesPaint(1, Color.red);
        Shape square = new Rectangle2D.Float(-2.0f, -2.0f, 4.0f, 4.0f);
        renderer.setSeriesShape(1, square, false);
    }
    if (data.length > 2) {
        renderer.setSeriesPaint(2, Color.darkGray);
        Shape rect = new Rectangle2D.Float(-2.0f, -1.0f, 4.0f, 2.0f);
        renderer.setSeriesShape(2, rect, false);
    }
    if (data.length > 3) {
        renderer.setSeriesPaint(3, Color.magenta);
        Shape rect = new Rectangle2D.Float(-1.0f, -2.0f, 2.0f, 4.0f);
        renderer.setSeriesShape(3, rect, false);
    }

    for (int i = 0; i < data.length; i++) {
        if (showShapes.length > i && !showShapes[i]) {
            renderer.setSeriesShapesVisible(i, false);
        }
    }

    XYAnnotation an = new XYTextAnnotation(annotation, maxX - 0.01, maxY);
    plot.addAnnotation(an);

    renderer.setUseFillPaint(true);

    final MyChartFrame graphFrame = new MyChartFrame(title, chart);
    graphFrame.getChartPanel().setMouseWheelEnabled(true);
    graphFrame.pack();
    graphFrame.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent arg0) {
            graphFrame.dispose();
        }
    });

    graphFrame.setVisible(true);

    return graphFrame;
}

From source file:be.ugent.maf.cellmissy.gui.controller.analysis.doseresponse.DoseResponseController.java

/**
 * Create a dose-response chart containing experimental data, simulated data
 * and an annotated R value./*w w  w. jav a  2  s. c  o m*/
 *
 * @param dataToPlot The experimental data on which the fit was performed
 * @param analysisGroup The analysis group
 * @param normalized Whether the responses are normalized
 * @return
 */
public JFreeChart createDoseResponseChart(List<DoseResponsePair> dataToPlot,
        DoseResponseAnalysisGroup analysisGroup, boolean normalized) {
    // setup scatter data of experimental concentrations/slopes, renderer and axis
    XYSeriesCollection experimentalData = new XYSeriesCollection();
    XYSeries scatterXYSeries = JFreeChartUtils.generateXYSeries(AnalysisUtils.generateXValues(dataToPlot),
            AnalysisUtils.generateYValues(dataToPlot));
    scatterXYSeries.setKey("Experimental data");
    experimentalData.addSeries(scatterXYSeries);

    // compute how far the simulated data and axes should range: from the lowest and highest dose continue half of the range between these two
    List<Double> extremes = new ArrayList<>();
    Double range = Math.abs(scatterXYSeries.getMaxX() - scatterXYSeries.getMinX());
    extremes.add(scatterXYSeries.getMinX() - (range / 2));
    extremes.add(scatterXYSeries.getMaxX() + (range / 2));

    // Create the simulated line data, renderer, and axis
    XYSeriesCollection fitting = new XYSeriesCollection();
    // create xy series of simulated data from the parameters from the fitting
    SigmoidFittingResultsHolder resultsHolder = analysisGroup.getDoseResponseAnalysisResults()
            .getFittingResults(normalized);
    XYSeries fittingData = simulateData(resultsHolder, extremes);
    fittingData.setKey("Fitting");
    fitting.addSeries(fittingData);

    XYPlot plot = JFreeChartUtils.setupDoseResponseDatasets(experimentalData, fitting,
            getPlotAxesNames(normalized), extremes);

    // show the r squared value, put the value at a certain place between the min and max dose
    double xPlace = extremes.get(1) - range;
    double yPlace = scatterXYSeries.getMinY() + ((scatterXYSeries.getMaxY() - scatterXYSeries.getMinY()) / 4);
    plot.addAnnotation(new XYTextAnnotation(
            "R2=" + AnalysisUtils.roundThreeDecimals(AnalysisUtils.computeRSquared(dataToPlot, resultsHolder)),
            xPlace, yPlace));

    // Create the chart with the plot and no legend
    JFreeChart chart = new JFreeChart("Title", JFreeChart.DEFAULT_TITLE_FONT, plot, false);
    String title = "";
    if (normalized) {
        title = "Normalized fitting";
    } else {
        title = "Initial fitting";
    }
    JFreeChartUtils.setupDoseResponseChart(chart, title);
    return chart;
}

From source file:org.jfree.data.xy.XYSeriesCollection.java

/**
 * Returns the minimum x-value in the dataset.
 *
 * @param includeInterval  a flag that determines whether or not the
 *                         x-interval is taken into account.
 *
 * @return The minimum value.//from ww w  .ja  v  a2  s.co  m
 */
@Override
public double getDomainLowerBound(boolean includeInterval) {
    if (includeInterval) {
        return this.intervalDelegate.getDomainLowerBound(includeInterval);
    }
    double result = Double.NaN;
    int seriesCount = getSeriesCount();
    for (int s = 0; s < seriesCount; s++) {
        XYSeries series = getSeries(s);
        double lowX = series.getMinX();
        if (Double.isNaN(result)) {
            result = lowX;
        } else {
            if (!Double.isNaN(lowX)) {
                result = Math.min(result, lowX);
            }
        }
    }
    return result;
}

From source file:org.jfree.data.xy.XYSeriesCollection.java

/**
 * Returns the range of the values in this dataset's domain.
 *
 * @param includeInterval  a flag that determines whether or not the
 *                         x-interval is taken into account.
 *
 * @return The range (or <code>null</code> if the dataset contains no
 *     values).//from   ww  w  .ja v  a 2s .c o m
 */
@Override
public Range getDomainBounds(boolean includeInterval) {
    if (includeInterval) {
        return this.intervalDelegate.getDomainBounds(includeInterval);
    } else {
        double lower = Double.POSITIVE_INFINITY;
        double upper = Double.NEGATIVE_INFINITY;
        int seriesCount = getSeriesCount();
        for (int s = 0; s < seriesCount; s++) {
            XYSeries series = getSeries(s);
            double minX = series.getMinX();
            if (!Double.isNaN(minX)) {
                lower = Math.min(lower, minX);
            }
            double maxX = series.getMaxX();
            if (!Double.isNaN(maxX)) {
                upper = Math.max(upper, maxX);
            }
        }
        if (lower > upper) {
            return null;
        } else {
            return new Range(lower, upper);
        }
    }
}

From source file:com.imaging100x.tracker.TrackerUtils.java

/**
* Create a frame with a plot of the data given in XYSeries
*///from  ww  w .  j  a va2s. co m
public static void plotData(String title, final XYSeries data, String xTitle, String yTitle, int xLocation,
        int yLocation) {
    // JFreeChart code
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(data);
    JFreeChart chart = ChartFactory.createScatterPlot(title, // Title
            xTitle, // x-axis Label
            yTitle, // y-axis Label
            dataset, // Dataset
            PlotOrientation.VERTICAL, // Plot Orientation
            false, // Show Legend
            true, // Use tooltips
            false // Configure chart to generate URLs?
    );
    final XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setRangeGridlinePaint(Color.lightGray);
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setBaseShapesVisible(true);
    renderer.setSeriesPaint(0, Color.black);
    renderer.setSeriesFillPaint(0, Color.white);
    renderer.setSeriesLinesVisible(0, true);
    Shape circle = new Ellipse2D.Float(-2.0f, -2.0f, 4.0f, 4.0f);
    renderer.setSeriesShape(0, circle, false);
    renderer.setUseFillPaint(true);

    ChartFrame graphFrame = new ChartFrame(title, chart);
    graphFrame.getChartPanel().setMouseWheelEnabled(true);
    graphFrame.setPreferredSize(new Dimension(SIZE, SIZE));
    graphFrame.setResizable(true);
    graphFrame.pack();
    graphFrame.setLocation(xLocation, yLocation);
    graphFrame.setVisible(true);

    dataset.addChangeListener(new DatasetChangeListener() {

        public void datasetChanged(DatasetChangeEvent dce) {
            double xRange = data.getMaxX() - data.getMinX();
            double yRange = data.getMaxY() - data.getMinY();
            double xAvg = (data.getMaxX() + data.getMinX()) / 2;
            double yAvg = (data.getMaxY() + data.getMinY()) / 2;
            double range = xRange;
            if (yRange > range) {
                range = yRange;
            }
            double offset = 0.55 * range;
            plot.getDomainAxis().setRange(xAvg - offset, xAvg + offset);
            plot.getRangeAxis().setRange(yAvg - offset, yAvg + offset);
        }

    });

}