Example usage for org.jfree.data.xy XYSeriesCollection addSeries

List of usage examples for org.jfree.data.xy XYSeriesCollection addSeries

Introduction

In this page you can find the example usage for org.jfree.data.xy XYSeriesCollection addSeries.

Prototype

public void addSeries(XYSeries series) 

Source Link

Document

Adds a series to the collection and sends a DatasetChangeEvent to all registered listeners.

Usage

From source file:ui.Graph.java

/**
 * Creates a chart.//from w ww.ja  v  a 2  s .c om
 *
 * @param dataset
 *            the data for the chart.
 *
 * @return a chart.
 */
private JFreeChart createChart(ArrayList<Setpoint> setpoints, ArrayList<Setpoint> traj) {
    trajectory = traj;

    XYSeries posSeries = new XYSeries("Position");
    XYSeries trajSeries = new XYSeries("Trajectory");
    XYSeries velSeries = new XYSeries("Velocity");
    for (int i = 0; i < setpoints.size(); i++) {

        Setpoint p = setpoints.get(i);
        posSeries.add(p.time, p.position);
        velSeries.add(p.time, p.velocity);
    }

    for (int i = 0; i < trajectory.size(); i++) {

        Setpoint p = trajectory.get(i);
        trajSeries.add(p.time, p.position);

    }

    XYSeriesCollection posDataset = new XYSeriesCollection();
    XYSeriesCollection trajDataset = new XYSeriesCollection();
    XYSeriesCollection velDataset = new XYSeriesCollection();

    posDataset.addSeries(posSeries);
    velDataset.addSeries(velSeries);
    trajDataset.addSeries(trajSeries);
    // create the chart...
    final JFreeChart chart = ChartFactory.createScatterPlot("System output", // chart title
            "X", // x axis label
            "Y", // y axis label
            posDataset, // data
            PlotOrientation.VERTICAL, true, // include legend
            true, // tooltips
            false // urls
    );

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
    chart.setBackgroundPaint(Color.white);

    // final StandardLegend legend = (StandardLegend) chart.getLegend();
    // legend.setDisplaySeriesShapes(true);
    // get a reference to the plot for further customisation...
    final XYPlot plot = chart.getXYPlot();

    plot.setDataset(0, posDataset);
    plot.setDataset(1, trajDataset);
    plot.setDataset(2, velDataset);
    plot.setBackgroundPaint(Color.white);
    // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.lightGray);

    XYLineAndShapeRenderer posRenderer = new XYLineAndShapeRenderer();
    // renderer.setSeriesShape(0, new Ellipse2D.Float(1.0f, 1.0f, 1.0f,
    // 1.0f));
    posRenderer.setSeriesPaint(0, Color.BLUE);
    posRenderer.setSeriesLinesVisible(0, true);
    posRenderer.setSeriesShapesVisible(0, false);
    XYStepRenderer trajRenderer = new XYStepRenderer();
    trajRenderer.setSeriesPaint(1, Color.RED);
    trajRenderer.setSeriesStroke(1, new BasicStroke(10));
    trajRenderer.setSeriesLinesVisible(1, true);
    trajRenderer.setSeriesShapesVisible(1, false);

    XYLineAndShapeRenderer velRenderer = new XYLineAndShapeRenderer();
    velRenderer.setSeriesPaint(0, Color.MAGENTA);
    velRenderer.setSeriesLinesVisible(0, true);
    velRenderer.setSeriesShapesVisible(0, false);
    // renderer.setSeriesStroke(1, new BasicStroke(0.01f));
    plot.setRenderer(0, posRenderer);
    plot.setRenderer(1, trajRenderer);
    plot.setRenderer(2, velRenderer);

    for (Setpoint s : trajectory) {
        Marker marker = new ValueMarker(s.time);
        marker.setPaint(Color.DARK_GRAY);
        marker.setLabel(Float.toString((float) s.position));
        marker.setLabelAnchor(RectangleAnchor.TOP_LEFT);
        marker.setLabelTextAnchor(TextAnchor.TOP_RIGHT);
        plot.addDomainMarker(marker);
    }

    XYTextAnnotation p = new XYTextAnnotation("kP = " + gains.kP, plot.getDomainAxis().getUpperBound() * 0.125,
            plot.getRangeAxis().getUpperBound() * .75);
    p.setFont(new Font("Dialog", Font.PLAIN, 12));
    plot.addAnnotation(p);
    XYTextAnnotation i = new XYTextAnnotation("kI = " + gains.kI, plot.getDomainAxis().getUpperBound() * 0.125,
            plot.getRangeAxis().getUpperBound() * .7);
    i.setFont(new Font("Dialog", Font.PLAIN, 12));
    plot.addAnnotation(i);
    XYTextAnnotation d = new XYTextAnnotation("kD = " + gains.kD, plot.getDomainAxis().getUpperBound() * 0.125,
            plot.getRangeAxis().getUpperBound() * .65);
    d.setFont(new Font("Dialog", Font.PLAIN, 12));
    plot.addAnnotation(d);

    // change the auto tick unit selection to integer units only...
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setAutoRange(true);
    // OPTIONAL CUSTOMISATION COMPLETED.

    return chart;

}

From source file:be.vds.jtbdive.client.view.core.dive.profile.DiveProfileChartPanelEditor.java

private Component createChartPanel() {
    depthSerie = new XYSeries("depth");
    XYSeriesCollection depthCollection = new XYSeriesCollection();
    depthCollection.addSeries(depthSerie);

    JFreeChart chart = ChartFactory.createXYLineChart("",
            I18nResourceManager.sharedInstance().getString("time"),
            I18nResourceManager.sharedInstance().getString("depth"), depthCollection, PlotOrientation.VERTICAL,
            true, true, false);//from ww w .j  a  v a  2  s . c o  m
    plot = chart.getXYPlot();
    Paint p = new GradientPaint(0f, 0f, UIAgent.getInstance().getColorWaterBottom(), 200f, 200f,
            UIAgent.getInstance().getColorWaterSurface(), false);
    plot.setBackgroundPaint(p);

    XYAreaRenderer renderer0 = new XYAreaRenderer();
    renderer0.setOutline(true);
    renderer0.setBaseOutlinePaint(UIAgent.getInstance().getColorProfileEdition());

    Color baseColor = UIAgent.getInstance().getColorBaseBackground();
    renderer0.setSeriesPaint(0, new Color(baseColor.getRed(), baseColor.getGreen(), baseColor.getBlue(), 50));
    plot.setRenderer(0, renderer0);

    dAxis = new NumberAxis();
    rAxis = new NumberAxis();
    // dAxis.setAutoRange(false);
    // rAxis.setAutoRange(false);
    // dAxis.setRange(0, maxTime);
    // rAxis.setRange(lowestDepth, 0);
    plot.setDomainAxis(dAxis);
    plot.setRangeAxis(rAxis);

    // plot.setRangeCrosshairLockedOnData(false);
    // plot.setDomainCrosshairLockedOnData(false);
    ((NumberAxis) plot.getDomainAxis()).setNumberFormatOverride(new MinutesNumberFormat());

    panel = new ChartPanel(chart);
    // panel.addChartMouseListener(new ChartMouseListener() {
    //
    // @Override
    // public void chartMouseMoved(ChartMouseEvent arg0) {
    // // TODO Auto-generated method stub
    //
    // }
    //
    // @Override
    // public void chartMouseClicked(ChartMouseEvent evt) {
    //
    // double x = plot.getDomainAxis().java2DToValue(
    // panel.translateScreenToJava2D(
    // evt.getTrigger().getPoint()).getX(),
    // panel.getChartRenderingInfo().getPlotInfo()
    // .getDataArea(), plot.getDomainAxisEdge());
    //
    // double y = plot.getRangeAxis().java2DToValue(
    // panel.translateScreenToJava2D(
    // evt.getTrigger().getPoint()).getY(),
    // panel.getChartRenderingInfo().getPlotInfo()
    // .getDataArea(), plot.getRangeAxisEdge());
    //
    // diveProfileEditor.addEntry(x, y, this);
    // }
    // });

    createDecoWarningCollection();
    createAscentTooFastCollection();
    createRemainBottomTimeCollection();
    createDecoEntriesCollection();

    return panel;
}

From source file:org.gephi.statistics.plugin.Hits.java

/**
 *
 * @return//from ww w .  j  a  v a 2  s . c  om
 */
public String getReport() {
    //distribution of hub values
    Map<Double, Integer> distHubs = new HashMap<Double, Integer>();
    for (Node node : hub_list) {
        int n_index = indicies.get(node);
        Double d = hubs[n_index];
        if (distHubs.containsKey(d)) {
            Integer v = distHubs.get(d);
            distHubs.put(d, v + 1);
        } else {
            distHubs.put(d, 1);
        }
    }

    //distribution of authority values
    Map<Double, Integer> distAuthorities = new HashMap<Double, Integer>();
    for (Node node : auth_list) {
        int n_index = indicies.get(node);
        Double d = authority[n_index];
        if (distAuthorities.containsKey(d)) {
            Integer v = distAuthorities.get(d);
            distAuthorities.put(d, v + 1);
        } else {
            distAuthorities.put(d, 1);
        }
    }

    //Distribution of hub series
    XYSeries dHubsSeries = ChartUtils.createXYSeries(distHubs, "Hubs");

    //Distribution of authority series
    XYSeries dAuthsSeries = ChartUtils.createXYSeries(distAuthorities, "Authority");

    XYSeriesCollection datasetHubs = new XYSeriesCollection();
    datasetHubs.addSeries(dHubsSeries);

    XYSeriesCollection datasetAuths = new XYSeriesCollection();
    datasetAuths.addSeries(dAuthsSeries);

    JFreeChart chart = ChartFactory.createXYLineChart("Hubs Distribution", "Score", "Count", datasetHubs,
            PlotOrientation.VERTICAL, true, false, false);
    chart.removeLegend();
    ChartUtils.decorateChart(chart);
    ChartUtils.scaleChart(chart, dHubsSeries, true);
    String imageFile1 = ChartUtils.renderChart(chart, "hubs.png");

    JFreeChart chart2 = ChartFactory.createXYLineChart("Authority Distribution", "Score", "Count", datasetAuths,
            PlotOrientation.VERTICAL, true, false, false);
    chart2.removeLegend();
    ChartUtils.decorateChart(chart2);
    ChartUtils.scaleChart(chart2, dAuthsSeries, true);
    String imageFile2 = ChartUtils.renderChart(chart2, "authorities.png");

    String report = "<HTML> <BODY> <h1> HITS Metric Report </h1>" + "<hr>" + "<br />"
            + "<h2> Parameters: </h2>  &#917; = " + this.epsilon + "<br /> <h2> Results: </h2><br />"
            + imageFile1 + "<br />" + imageFile2 + "<br /><br />" + "<h2> Algorithm: </h2>"
            + "Jon M. Kleinberg, <i>Authoritative Sources in a Hyperlinked Environment</i>, in Journal of the ACM 46 (5): 604632 (1999)<br />"
            + "</BODY> </HTML>";

    return report;
}

From source file:fungus.UtilizationChartFrame.java

public UtilizationChartFrame(String prefix) {
    simulationCycles = Configuration.getDouble(PAR_SIMULATION_CYCLES);
    this.setTitle("MycoNet Statistics Chart");
    graph = JungGraphObserver.getGraph();

    //data.add(-1,0);
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.setAutoWidth(false);//w  w w .j  a  v  a 2  s.  co m
    dataset.setIntervalWidth(simulationCycles);

    averageUtilizationData = new XYSeries("Average Utilization");
    dataset.addSeries(averageUtilizationData);
    averageStableUtilizationData = new XYSeries("Avg Stable Util");
    dataset.addSeries(averageStableUtilizationData);
    hyphaRatioData = new XYSeries("Hypha Ratio");
    dataset.addSeries(hyphaRatioData);
    stableHyphaRatioData = new XYSeries("Stable Hypha Ratio");
    dataset.addSeries(stableHyphaRatioData);

    //XYSeriesCollection dataset;

    JFreeChart utilizationChart = ChartFactory.createXYLineChart("Utilization Metrics", "Cycle",
            "Average Utilization", dataset, PlotOrientation.VERTICAL, true, false, false);
    ChartPanel utilizationChartPanel = new ChartPanel(utilizationChart);

    //chart.setBackgroundPaint(Color.white);
    //XYPlot plot = chart.getXYPlot();

    //        BufferedImage chartImage = chart.createBufferedImage(500,300);
    //        chartLabel = new JLabel();
    //chartLabel.setIcon(new ImageIcon(chartImage));

    Container contentPane = getContentPane();
    contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.PAGE_AXIS));
    JPanel labelPane = new JPanel();
    labelPane.setLayout(new GridLayout(1, 1));
    //chartPane.setPreferredSize(new java.awt.Dimension(500, 300));
    JPanel buttonPane = new JPanel();
    buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));

    ////contentPane.add(labelPane,BorderLayout.PAGE_START);
    //contentPane.add(Box.createRigidArea(new Dimension(0,5)));
    contentPane.add(utilizationChartPanel, BorderLayout.CENTER);
    //contentPane.add(Box.createRigidArea(new Dimension(0,5)));
    ////contentPane.add(buttonPane, BorderLayout.PAGE_END);

    //data = node.getHyphaData();
    //link = node.getHyphaLink();
    //mycocast = node.getMycoCast();

    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

    //chartPanel.add(chartLabel);

    /*JButton updateButton = new JButton("Refresh");
      ActionListener updater = new ActionListener() {
      public void actionPerformed(ActionEvent e) {
      refreshData();
      }
      };
      updateButton.addActionListener(updater);
            
      JButton closeButton = new JButton("Close");
      ActionListener closer = new ActionListener() {
      public void actionPerformed(ActionEvent e) {
      closeFrame();
      }
      };
      closeButton.addActionListener(closer);
            
      buttonPane.add(Box.createHorizontalGlue());
      buttonPane.add(updateButton);
      buttonPane.add(Box.createRigidArea(new Dimension(5,0)));
      buttonPane.add(closeButton);
      refreshData();
    */

    //JungGraphObserver.addChangeListener(this);

    this.pack();
    this.setVisible(true);
}

From source file:visualizer.datamining.dataanalysis.CreateLineGraph.java

private XYDataset createAllSeries(ArrayList<Serie> series) throws IOException {
    XYSeriesCollection xyseriescollection = new XYSeriesCollection();

    for (int i = 0; i < series.size(); i++) {
        XYSeries xyseries = this.createSerie(series.get(i).name, series.get(i).values);
        xyseriescollection.addSeries(xyseries);
    }/*from   w w w .  jav  a  2 s .com*/

    return xyseriescollection;
}

From source file:Charts.LineChart.java

private XYSeriesCollection createDataset() {
    final XYSeriesCollection dataset = new XYSeriesCollection();
    // Acces tableau
    for (int i = 0; i < super.values.length; i++) {
        final XYSeries serie = new XYSeries(i);
        // Acces ArrayList
        for (int j = 0; j < super.values[i].size(); j++) {

            serie.add(super.values[i].get(j).key(), super.values[i].get(j).value());
        }//from  w  w  w. j ava 2 s . co  m
        dataset.addSeries(serie);
    }
    return dataset;
}

From source file:carfuzzy.Operations.java

public JFreeChart setToChart(double input, double membership, XYSeries series, XYSeriesCollection collection,
        String x_axis) { // kurallari cizdirdikten sonra cizdir.

    series.add(input, membership);//  ww  w .j a v  a 2  s.  c om
    series.add(input, 0);
    series.add(0, membership);
    collection.addSeries(series);

    JFreeChart chart = XYGraph.drawChart(collection, x_axis, "Membership");
    XYPlot plot = chart.getXYPlot();
    XYItemRenderer renderer = plot.getRenderer();

    renderer.setSeriesStroke(collection.getSeriesCount() - 1, new BasicStroke(3.5f));
    renderer.setSeriesStroke(collection.getSeriesCount() - 1, new BasicStroke(3.5f));
    plot.setRenderer(renderer);
    return chart;
}

From source file:org.usfirst.frc.team2084.neuralnetwork.HeadingNeuralNetworkTrainer.java

public HeadingNeuralNetworkTrainer() {
    outputGraphNetworkSeries = new XYSeries("Network Prediction");
    outputGraphDataSeries = new XYSeries("Error");
    final XYSeriesCollection data = new XYSeriesCollection();
    data.addSeries(outputGraphDataSeries);
    data.addSeries(outputGraphNetworkSeries);
    outputGraph = ChartFactory.createXYLineChart("Error vs. Output", "Time", "Error", data,
            PlotOrientation.VERTICAL, true, true, false);

    NumberAxis xAxis = new NumberAxis();
    xAxis.setRange(new Range(-Math.PI, Math.PI));
    xAxis.setAutoRange(false);//from  w  w w. j  av a2  s .co  m
    NumberAxis yAxis = new NumberAxis();
    yAxis.setRange(new Range(-1, 1));

    XYPlot plot = (XYPlot) outputGraph.getPlot();
    plot.setDomainAxis(xAxis);
    plot.setRangeAxis(yAxis);

    network = new Network(new int[] { 1, 5, 1 }, eta, momentum, new TransferFunction.HyperbolicTangent());

    try {
        SwingUtilities.invokeAndWait(() -> {
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            final Container content = frame.getContentPane();
            content.setLayout(new BorderLayout());

            outputGraphPanel = new ChartPanel(outputGraph);
            outputGraphPanel.setDomainZoomable(false);
            outputGraphPanel.setRangeZoomable(false);
            graphPanel.add(outputGraphPanel);

            graphPanel.setLayout(new GridLayout(1, 1));
            content.add(graphPanel, BorderLayout.CENTER);
            {

                JLabel etaLabel = new JLabel("Eta:");
                etaLabel.setLabelFor(etaField);
                etaField.setText(Double.toString(network.getEta()));
                etaField.setColumns(5);
                etaField.addPropertyChangeListener("value",
                        (evt) -> eta = ((Number) evt.getNewValue()).doubleValue());
                controlPanel.add(etaLabel);
                controlPanel.add(etaField);

                JLabel momentumLabel = new JLabel("Momentum:");
                momentumLabel.setLabelFor(etaField);
                momentumField.setText(Double.toString(network.getMomentum()));
                momentumField.setColumns(5);
                momentumField.addPropertyChangeListener("value",
                        (evt) -> momentum = ((Number) evt.getNewValue()).doubleValue());
                controlPanel.add(momentumLabel);
                controlPanel.add(momentumField);

                JLabel iterationsLabel = new JLabel("Iterations:");
                iterationsLabel.setLabelFor(iterationsField);
                iterationsField.setText(Integer.toString(iterations));
                iterationsField.setColumns(10);
                iterationsField.addPropertyChangeListener("value",
                        (evt) -> iterations = ((Number) evt.getNewValue()).intValue());
                controlPanel.add(iterationsLabel);
                controlPanel.add(iterationsField);
            }

            chooseDataButton.addActionListener((e) -> {
                if (dataDirectoryChooser.showOpenDialog(frame) == JFileChooser.APPROVE_OPTION) {
                    dataDirectory = dataDirectoryChooser.getSelectedFile();
                    displayData();
                }
            });
            controlPanel.add(chooseDataButton);

            trainButton.addActionListener((e) -> trainNetwork());
            controlPanel.add(trainButton);

            saveButton.addActionListener((e) -> {
                saveNetwork();
            });
            controlPanel.add(saveButton);

            content.add(controlPanel, BorderLayout.SOUTH);

            dataDirectoryChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.pack();
            frame.setVisible(true);
        });
    } catch (InvocationTargetException | InterruptedException e) {
        e.printStackTrace();
    }
}

From source file:eremeykin.pete.plotter.CartesianPlotterTopComponent.java

public CartesianPlotterTopComponent() {
    initComponents();//from w  ww  . ja v  a 2  s .  c om
    setName(Bundle.CTL_CartesianPlotterTopComponent());
    setToolTipText(Bundle.HINT_CartesianPlotterTopComponent());
    final XYSeriesCollection dataset = new XYSeriesCollection();

    final XYSeries toleranceSeries = new XYSeries("Tolerance");
    final XYSeries dataSeries = new XYSeries("U");

    dataset.addSeries(dataSeries);
    dataset.addSeries(toleranceSeries);
    final JFreeChart chart = createChart(dataset);
    chartPanel = new ChartPanel(chart);
    setLayout(new java.awt.BorderLayout());
    add(chartPanel, BorderLayout.CENTER);
    validate();

}

From source file:mil.tatrc.physiology.biogears.verification.ScenarioPlotTool.java

public void createGraph(String toDir, Paint color, String title, String XAxisLabel, String YAxisLabel,
        XYSeries... xyData) {/*from ww  w  . ja va 2s  .com*/
    new File(toDir).mkdir();

    Log.info("Creating Graph " + toDir + title);
    double resMin0 = 1.e6;
    double resMax0 = -1.e6;
    double resMin1 = 1.e6;
    double resMax1 = -1.e6;

    XYSeriesCollection dataSet = new XYSeriesCollection();
    for (XYSeries data : xyData)
        dataSet.addSeries(data);

    JFreeChart chart = ChartFactory.createXYLineChart(title, // chart title
            XAxisLabel, // x axis label
            YAxisLabel, // y axis label
            dataSet, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips
            false // urls
    );

    XYPlot plot = (XYPlot) chart.getPlot();

    if (title.contains("Residual")) {
        // Make plot symmetric about x axis
        resMax0 = xyData[0].getMaxY();
        resMin0 = xyData[0].getMinY();
        if (Math.abs(xyData[0].getMinY()) > Math.abs(xyData[0].getMaxY()))
            resMax0 = Math.abs(resMin0);
        if (Math.abs(xyData[0].getMaxY()) > Math.abs(xyData[0].getMinY()))
            resMin0 = -1.0 * Math.abs(resMax0);
        if ((resMin0 == 0.0) && (resMax0 == 0.0)) {
            resMin0 = -0.00001;
            resMax0 = 0.00001;
        }
        ValueAxis yAxis = plot.getRangeAxis();
        yAxis.setRange(resMin0 + 0.05 * resMin0, resMax0 + 0.05 * resMax0);//5% buffer so we can see top and bottom clearly
    } else if (title.contains("Error")) {
        // Make plot symmetric about x axis
        resMax0 = xyData[0].getMaxY();
        resMin0 = xyData[0].getMinY();
        if ((resMin0 == 0.0) && (resMax0 == 0.0)) {
            resMin0 = -0.00001;
            resMax0 = 0.00001;
        }
        if (resMin0 >= 0.0)
            resMin0 = -0.01;
        ValueAxis yAxis = plot.getRangeAxis();
        yAxis.setRange(resMin0 + 0.05 * resMin0, resMax0 + 0.05 * resMax0);//5% buffer so we can see top and bottom clearly

        /*
         yAxis.setTickLabelPaint(new Color(1,0,0));
         yAxis.setTickMarkPaint(new Color(1,0,0));
         yAxis.setAxisLinePaint(new Color(1,0,0));
         yAxis.setLabelPaint(new Color(1,0,0));
                
         ValueAxis xAxis = plot.getDomainAxis();
         xAxis.setTickLabelPaint(new Color(1,0,0));
         xAxis.setTickMarkPaint(new Color(1,0,0));
         yAxis.setAxisLinePaint(new Color(1,0,0));
         yAxis.setLabelPaint(new Color(1,0,0));
         */
    } else {
        if (xyData.length > 1) {
            // Make plot symmetric about x axis
            resMax0 = xyData[0].getMaxY();
            resMin0 = xyData[0].getMinY();
            resMax1 = xyData[1].getMaxY();
            resMin1 = xyData[1].getMinY();
            if (resMin1 < resMin0)
                resMin0 = resMin1;
            if (resMax1 > resMax0)
                resMax0 = resMax1;
            if ((resMin0 == 0.0) && (resMax0 == 0.0)) {
                resMin0 = -0.00001;
                resMax0 = 0.00001;
            }
            if (resMin0 >= 0.0)
                resMin0 = -0.01;
            if (YAxisLabel.indexOf("PlasmaConcentration") > -1)
                plot.setRangeAxis(new LogarithmicAxis("Log(" + YAxisLabel + ")"));
            else {
                ValueAxis yAxis = plot.getRangeAxis();
                yAxis.setRange(resMin0 + 0.05 * resMin0, resMax0 + 0.05 * resMax0);//5% buffer so we can see top and bottom clearly
            }
        } else {
            // Make plot symmetric about x axis
            resMax0 = xyData[0].getMaxY();
            resMin0 = xyData[0].getMinY();
            if ((resMin0 == 0.0) && (resMax0 == 0.0)) {
                resMin0 = -0.00001;
                resMax0 = 0.00001;
            }
            if (resMin0 >= 0.0)
                resMin0 = -0.01;
            if (YAxisLabel.indexOf("PlasmaConcentration") > -1)
                plot.setRangeAxis(new LogarithmicAxis("Log(" + YAxisLabel + ")"));
            else {
                ValueAxis yAxis = plot.getRangeAxis();
                yAxis.setRange(resMin0 + 0.05 * resMin0, resMax0 + 0.05 * resMax0);//5% buffer so we can see top and bottom clearly
            }
        }
    }

    formatXYPlot(chart, color);
    //Changing line widths and colors
    XYItemRenderer r = plot.getRenderer();
    BasicStroke wideLine = new BasicStroke(lineWidth);
    r.setSeriesStroke(0, wideLine);
    r.setSeriesStroke(1, wideLine);
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    if (xyData.length > 1) {
        renderer.setSeriesStroke(//makes a dashed line
                0, //argument below float[]{I,K} -> alternates between solid and opaque (solid for I, opaque for K)
                new BasicStroke(lineWidth, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f,
                        new float[] { 15.0f, 30.0f }, 0.0f));
        renderer.setDrawSeriesLineAsPath(true);
        renderer.setUseFillPaint(true);
    }
    renderer.setBaseShapesVisible(false);
    renderer.setSeriesFillPaint(0, expectedLineColor);
    renderer.setSeriesFillPaint(1, computedLineColor);
    renderer.setSeriesPaint(0, expectedLineColor);
    renderer.setSeriesPaint(1, computedLineColor);

    try {
        if (toDir == null || toDir.isEmpty())
            toDir = ".";
        File JPGFile = new File(toDir + "/" + StringUtils.removeParens(title) + ".jpg");
        ChartUtilities.saveChartAsJPEG(JPGFile, chart, 1600, 800);
    } catch (IOException e) {
        Log.error(e.getMessage());
    }
}