Example usage for org.jfree.data.statistics HistogramDataset HistogramDataset

List of usage examples for org.jfree.data.statistics HistogramDataset HistogramDataset

Introduction

In this page you can find the example usage for org.jfree.data.statistics HistogramDataset HistogramDataset.

Prototype

public HistogramDataset() 

Source Link

Document

Creates a new (empty) dataset with a default type of HistogramType .FREQUENCY.

Usage

From source file:OAT.trading.thread.BacktestThread.java

private void showHistogram(String title, double[] data) {
    if (data == null || data.length == 0) {
        return;/*from ww  w .ja  va  2 s.c om*/
    }

    HistogramDataset histogramDataset = new HistogramDataset();
    histogramDataset.addSeries(title, data, 15);

    JFreeChart chart = ChartFactory.createHistogram("", "", "", histogramDataset, PlotOrientation.VERTICAL,
            false, false, false);

    new BasicChartFrame(title, chart).setVisible(true);
}

From source file:org.fhcrc.cpl.viewer.amt.commandline.AmtDatabaseDiagnosticCommandLineModule.java

/**
 *
 * @return/*from  w  w w.j ava 2 s  . c o  m*/
 */
protected JFreeChart histogramIDProbs() {
    HistogramDataset dataset = new HistogramDataset();

    List<Double> histDataList = new ArrayList<Double>();

    AmtPeptideEntry[] entries = amtDB.getEntries();
    for (AmtPeptideEntry entry : entries) {
        if (entry.getNumObservations() > 1)
            histDataList.add((double) entry.calculateIDProbability());
    }
    double[] histData = new double[histDataList.size()];

    for (int i = 0; i < histData.length; i++)
        histData[i] = histDataList.get(i);

    ApplicationContext.setMessage("Mean ID probability: " + BasicStatistics.mean(histData));

    dataset.addSeries("ID probablity", histData, 200);

    JFreeChart chart = ChartFactory.createHistogram("id_probability", "id_probability", "id_probability",
            dataset, PlotOrientation.VERTICAL, false, false, false);
    PanelWithChart pwc = new PanelWithChart(chart);
    pwc.setName("id probs");

    if (showCharts)
        pwc.displayInTab();
    return pwc.getChart();
}

From source file:v800_trainer.JHistogram.java

public JPanel StartHistoSchrittlnge(JCicloTronic JTronicHandle) {

    boolean Summenhisto;
    int von = 0;//from   ww  w .  j a v  a2 s.  c o  m
    int bis = 0;
    int num = 0;
    int selected;
    int single;
    int Gruppen = 0;
    int i = 100;
    int j = 10;
    int m = 0;
    int n = 0;
    int Linecount = 0;
    int Anzahl = 1;

    JFreeChart chart;

    double DummyData[] = new double[1];

    selected = JTronicHandle.Auswahl_Histogramm.getSelectedIndex();
    Summenhisto = JTronicHandle.Summenhistogramm_Check.isSelected();

    chart = ChartFactory.createHistogram("", "Schrittlnge [cm]", "Hufigkeit", new HistogramDataset(),
            PlotOrientation.HORIZONTAL, true, true, true);

    chart.setBackgroundPaint(Color.white);

    JTronicHandle.applyChartTheme(chart);

    XYPlot plot = chart.getXYPlot();
    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);

    ArrayList Bufferarray = new ArrayList();
    double Buffer;

    if (selected == 0) {
        single = 1;
    } else {
        single = 0;
        Summenhisto = false;
    }

    try {
        von = Integer.parseInt(JTronicHandle.Properties.getProperty("HistovonSchrittlnge", "100"));
        bis = Integer.parseInt(JTronicHandle.Properties.getProperty("HistobisSchrittlnge", "200"));
        Gruppen = Integer.parseInt(JTronicHandle.Properties.getProperty("HistostepSchrittlnge", "10"));
        Anzahl = (JTronicHandle.Auswahl_Histogramm.getItemCount() - 2) * single + 1;
        for (j = 0; j < Anzahl; j++) {
            if (single == 1) {
                selected = j + 1;
            }
            if (!Summenhisto) {
                num = JTronicHandle.Statistikhandle.TourData[selected].Datenpunkte;
            } else {
                num += JTronicHandle.Statistikhandle.TourData[selected].Datenpunkte;
            }

            n = 0;
            if (!Summenhisto) {
                create_Start_Stop(JTronicHandle, selected); //die limits einer gezoomten Graphik ermitteln

                for (i = start; i < stop; i++) {
                    Buffer = (double) JTronicHandle.Statistikhandle.TourData[selected].Schritt_lnge[i];
                    if (Buffer >= von && Buffer <= bis) {
                        Bufferarray.add(Buffer);
                    }
                }
            } else {
                for (i = 0; i < j + 1; i++) {
                    create_Start_Stop(JTronicHandle, i + 1);
                    for (m = start; m < stop; m++) {
                        Buffer = (double) JTronicHandle.Statistikhandle.TourData[i + 1].Schritt_lnge[m];
                        if (Buffer >= von && Buffer <= bis) {
                            Bufferarray.add(Buffer);
                        }

                    }

                }
            }

            DummyData = new double[Bufferarray.size()];

            for (i = 0; i < Bufferarray.size(); i++) {
                DummyData[i] = new Double(Bufferarray.get(i).toString());
            }

            if (!Summenhisto) {
                HistogramDataset histoHM = new HistogramDataset();
                histoHM.addSeries(
                        "" + JTronicHandle.Statistikhandle.TourData[selected].Tag + "."
                                + JTronicHandle.Statistikhandle.TourData[selected].Monat + "."
                                + JTronicHandle.Statistikhandle.TourData[selected].Jahr,
                        DummyData, Gruppen, (double) von, (double) bis);
                histoHM.setType(HistogramType.RELATIVE_FREQUENCY);
                plot.setDataset(Linecount, histoHM);
                plot.mapDatasetToRangeAxis(Linecount, 0);
                XYBarRenderer renderer = new XYBarRenderer();
                renderer.setDrawBarOutline(true);

                renderer.setSeriesPaint(0, getColour(Linecount, (int) 255 / Anzahl));

                renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
                plot.setRenderer(Linecount, renderer);

            }
            Linecount++;
        }
    } catch (Exception e) {
        JOptionPane.showMessageDialog(null, "StartHistoSchrittlnge\nFehler: Hm " + e + " " + i + " " + j,
                "Achtung!", JOptionPane.ERROR_MESSAGE);
    }

    if (Summenhisto) {
        HistogramDataset histoHM = new HistogramDataset();
        histoHM.addSeries("Summenhistogram", DummyData, Gruppen, (double) von, (double) bis);
        histoHM.setType(HistogramType.RELATIVE_FREQUENCY);

        plot.setDataset(0, histoHM);
        plot.mapDatasetToRangeAxis(0, 0);
        XYItemRenderer renderer = new XYBarRenderer();
        renderer.setSeriesPaint(0, Color.blue);
        renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());

        plot.setRenderer(0, renderer);
    }
    chart.setPadding(padding);
    ChartPanel Panel = new ChartPanel(chart);

    return Panel;
}

From source file:playground.christoph.evacuation.analysis.EvacuationTimePictureWriter.java

private JFreeChart createHistogramChart(String transportMode, double[] travelTimes) {

    HistogramDataset dataset = new HistogramDataset();
    dataset.setType(HistogramType.RELATIVE_FREQUENCY);
    dataset.addSeries("evacuation travel time " + transportMode, travelTimes, 20);

    JFreeChart chart = ChartFactory.createHistogram(null, null, "frequency", dataset, PlotOrientation.VERTICAL,
            true, false, false);// ww  w . j ava2 s .  com
    chart.getXYPlot().setForegroundAlpha(0.75f);

    /*
     * set x-axis range 
     */
    double min = 0.0;
    double max = maxEvacuationTime;
    if (limitMaxEvacuationTime) {
        double cutOffValue = meanEvacuationTime + standardDeviation * evacuationTimeCutOffFactor;
        max = cutOffValue;
    }
    chart.getXYPlot().getDomainAxis().setLowerBound(min);
    chart.getXYPlot().getDomainAxis().setUpperBound(max);

    return chart;
}

From source file:org.fhcrc.cpl.viewer.amt.commandline.AmtDatabaseDiagnosticCommandLineModule.java

/**
 * Show a histogram of the standard deviations of hydrophobicity observations per peptide
 * @return/* w  w w.j a  va2s .  c  o m*/
 */
protected JFreeChart histogramHydroStdDev() {
    HistogramDataset dataset = new HistogramDataset();

    List<Double> histDataList = new ArrayList<Double>();

    AmtPeptideEntry[] entries = amtDB.getEntries();
    for (int i = 0; i < amtDB.numEntries(); i++) {
        if (entries[i].getNumObservations() > 1)
            histDataList.add(entries[i].getHydrophobicityStandardDeviation());
    }
    double[] histData = new double[histDataList.size()];

    for (int i = 0; i < histData.length; i++)
        histData[i] = histDataList.get(i);

    ApplicationContext.setMessage("Mean H standard deviation: " + BasicStatistics.mean(histData));

    dataset.addSeries("hyd_std_dev", histData, 100);

    JFreeChart chart = ChartFactory.createHistogram("hydstddev", "hydstddev", "hydstddev", dataset,
            PlotOrientation.VERTICAL, false, false, false);
    PanelWithChart pwc = new PanelWithChart(chart);
    pwc.setName("mean h std devs");

    if (showCharts)
        pwc.displayInTab();
    return pwc.getChart();
}

From source file:be.ugent.maf.cellmissy.gui.controller.analysis.singlecell.SingleCellAnalysisController.java

/**
 * For a single well, generate an histogram dataset.
 *
 * @param data//from w  w  w .ja  v a  2 s.  com
 * @param seriesKey
 * @param mapTo360
 * @return an HistogramDataset
 */
private HistogramDataset getHistogramDatasetForACondition(
        SingleCellConditionDataHolder singleCellConditionDataHolder, String seriesKey, int bins) {
    HistogramDataset dataset = new HistogramDataset();
    dataset.setType(HistogramType.RELATIVE_FREQUENCY);
    double[] toPrimitive = ArrayUtils.toPrimitive(
            AnalysisUtils.excludeNullValues(singleCellConditionDataHolder.getTurningAnglesVector()));

    double[] mappedData = new double[toPrimitive.length];
    for (int i = 0; i < toPrimitive.length; i++) {
        if (toPrimitive[i] > 0) {
            mappedData[i] = toPrimitive[i];
        } else {
            mappedData[i] = toPrimitive[i] + 360;
        }
    }
    double[] toAdd = mappedData;

    dataset.addSeries(seriesKey, toAdd, bins);
    return dataset;
}

From source file:org.fhcrc.cpl.viewer.amt.commandline.AmtDatabaseDiagnosticCommandLineModule.java

/**
 * Histogram all masses in the database/*from w  w  w  .ja  v a2s.c o  m*/
 * @return
 */
protected JFreeChart histogramMasses() {
    HistogramDataset dataset = new HistogramDataset();

    double[] histData = new double[amtDB.numEntries()];

    AmtPeptideEntry[] entries = amtDB.getEntries();
    for (int i = 0; i < amtDB.numEntries(); i++) {
        histData[i] = entries[i].getMass();

    }
    dataset.addSeries("masses", histData, 500);

    JFreeChart chart = ChartFactory.createHistogram("masses", "masses", "masses", dataset,
            PlotOrientation.VERTICAL, false, false, false);
    ChartDialog cd2 = new ChartDialog(chart);
    cd2.setSize(800, 600);
    PanelWithChart pwc = new PanelWithChart(chart);

    pwc.setName("masses");

    if (showCharts)
        pwc.displayInTab();
    return pwc.getChart();
}

From source file:simulation.AureoZauleckAnsLab2.java

public static JFreeChart createHistogram(ArrayList doubleMatrix, int width, String title, String label) {

    // Generate a one dimensional array of the size w*h of the double matrix
    ArrayList<Double> dataArrayList = new ArrayList<Double>();

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

        double value = Double.parseDouble(doubleMatrix.get(i).toString());
        if (Double.isNaN(value))
            continue;
        else//w ww  . ja v  a  2  s .  co  m
            dataArrayList.add(value);
        System.out.println(value);
    }

    double[] data = new double[dataArrayList.size()];

    for (int p = 0; p < dataArrayList.size(); p++)
        data[p] = dataArrayList.get(p);

    // int number = data.length;
    HistogramDataset dataset = new HistogramDataset();

    dataset.setType(HistogramType.FREQUENCY);
    dataset.addSeries("Hist", data, width);
    String plotTitle = title;
    String yAxis = "Frequency";
    String xAxis = label;
    PlotOrientation orientation = PlotOrientation.VERTICAL;

    boolean show = false;
    boolean toolTips = false;
    boolean urls = false;
    JFreeChart chart = ChartFactory.createHistogram(plotTitle, xAxis, yAxis, dataset, orientation, show,
            toolTips, urls);

    chart.setBackgroundPaint(Color.white);
    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 300));
    JFrame l = new JFrame();
    l.setContentPane(chartPanel);
    l.setSize(400, 400);
    l.setVisible(true);

    return chart;
}

From source file:net.bioclipse.chembl.moss.ui.wizard.ChemblMossWizardPage1.java

public void helpToHistogram(IStringMatrix matrix) {
    //Adds activity to histogram series
    series = new XYSeries("Activity for compounds");
    histogramSeries = new HistogramDataset();
    histogramSeries.setType(HistogramType.FREQUENCY);
    ArrayList<Double> activites = new ArrayList<Double>();
    double value;
    int cnt = 1;//w w  w  .j  a  v  a 2 s  . c  o  m
    double[] histact = new double[matrix.getRowCount() + 1];
    for (int i = 1; i < matrix.getRowCount() + 1; i++) {
        if (matrix.get(i, "actval").equals("")) {
            value = 0;
        } else {
            value = Double.parseDouble(matrix.get(i, "actval"));
        }
        activites.add(value);
    }
    //Sort list to increasing order of activities and adds them to histogram
    Collections.sort(activites);
    for (int i = 0; i < activites.size(); i++) {
        double d = activites.get(i);
        histact[i] = d;
        int t = activites.size() - 1;
        if (i == t) {
            series.add(d, cnt);
        } else {
            double dd = activites.get(i + 1);

            if (d == dd) {
                cnt++;
            } else {
                histact[i] = d;
                series.add(d, cnt);
                cnt = 1;
            }
        }
    }
    histogramSeries.addSeries("Histogram", histact, matrix.getRowCount());
}

From source file:MSUmpire.DIA.TargetMatchScoring.java

public void MixtureModeling() throws IOException {
    if (libTargetMatches.isEmpty()) {
        return;// ww  w .j a  v a2  s  .  c o m
    }
    int IDNo = 0;
    int decoyNo = 0;
    int modelNo = 0;
    double IDmean = 0d;
    double Decoymean = 0d;

    for (UmpireSpecLibMatch match : libIDMatches) {
        if (match.BestHit != null) {
            IDNo++;
            IDmean += match.BestHit.UmpireScore;
        }
    }

    decoyNo = decoyModelingList.size();
    for (PeakGroupScore peakGroupScore : decoyModelingList) {
        Decoymean += peakGroupScore.UmpireScore;
    }

    for (UmpireSpecLibMatch match : libTargetMatches) {
        //modelNo+= match.TargetHits.size();
        if (match.BestMS1Hit != null) {
            modelNo++;
        }
        if (match.BestMS2Hit != null) {
            modelNo++;
        }
    }

    Decoymean /= decoyNo;
    IDmean /= IDNo;

    PVector[] points = new PVector[modelNo];
    PVector[] centroids = new PVector[2];

    int idx = 0;
    for (UmpireSpecLibMatch match : libTargetMatches) {
        if (match.BestMS1Hit != null) {
            points[idx] = new PVector(1);
            points[idx].array[0] = match.BestMS1Hit.UmpireScore;
            idx++;
        }
        if (match.BestMS2Hit != null) {
            points[idx] = new PVector(1);
            points[idx].array[0] = match.BestMS2Hit.UmpireScore;
            idx++;
        }
        //            for(PeakGroupScore peakGroupScore : match.TargetHits){
        //                points[idx] = new PVector(1);
        //                points[idx].array[0] = match.BestMS2Hit.UmpireScore;
        //                idx++;
        //            }
    }

    MixtureModel mmc;
    centroids[0] = new PVector(1);
    centroids[0].array[0] = Decoymean;
    centroids[1] = new PVector(1);
    centroids[1].array[0] = IDmean;
    Vector<PVector>[] clusters = KMeans.run(points, 2, centroids);
    MixtureModel mm = ExpectationMaximization1D.initialize(clusters);
    mmc = ExpectationMaximization1D.run(points, mm);
    DecimalFormat df = new DecimalFormat("#.####");
    Logger.getRootLogger()
            .debug("----------------------------------------------------------------------------------------");
    Logger.getRootLogger().debug("No. of modeling points=" + modelNo);
    Logger.getRootLogger().debug("ID hits mean=" + df.format(IDmean));
    Logger.getRootLogger().debug("Decoy hits mean=" + df.format(Decoymean));
    //System.out.print("T-test: p-value=" + df.format(model.ttest.pValue).toString() + "\n");
    Logger.getRootLogger()
            .debug("Incorrect hits model mean=" + df.format(((PVector) mmc.param[0]).array[0]) + " variance="
                    + df.format(((PVector) mmc.param[0]).array[1]) + " weight=" + df.format(mmc.weight[0]));
    Logger.getRootLogger()
            .debug("Correct hits model mean=" + df.format(((PVector) mmc.param[1]).array[0]) + " variance="
                    + df.format(((PVector) mmc.param[1]).array[1]) + " weight=" + df.format(mmc.weight[1]));

    if (((PVector) mmc.param[0]).array[0] > ((PVector) mmc.param[1]).array[0]) {
        return;
    }

    float max = (float) (((PVector) mmc.param[1]).array[0] + 4 * Math.sqrt(((PVector) mmc.param[1]).array[1]));
    float min = (float) (((PVector) mmc.param[0]).array[0] - 4 * Math.sqrt(((PVector) mmc.param[0]).array[1]));

    IDNo = 0;
    decoyNo = 0;
    modelNo = 0;

    for (PeakGroupScore peakGroupScore : decoyModelingList) {
        if (peakGroupScore.UmpireScore > min && peakGroupScore.UmpireScore < max) {
            decoyNo++;
        }
    }

    for (UmpireSpecLibMatch match : libIDMatches) {
        if (match.BestHit != null && match.BestHit.UmpireScore > min && match.BestHit.UmpireScore < max) {
            IDNo++;
        }
    }

    for (UmpireSpecLibMatch match : libTargetMatches) {
        //targetNo += match.TargetHits.size();
        //decoyNo += match.DecoyHits.size();
        if (match.BestMS1Hit != null && match.BestMS1Hit.UmpireScore > min
                && match.BestMS1Hit.UmpireScore < max) {
            modelNo++;
        }
        if (match.BestMS2Hit != null && match.BestMS2Hit.UmpireScore > min
                && match.BestMS2Hit.UmpireScore < max) {
            modelNo++;
        }
        //modelNo += match.TargetHits.size();            
    }

    double[] IDObs = new double[IDNo];
    double[] DecoyObs = new double[decoyNo];
    double[] ModelObs = new double[modelNo];
    idx = 0;
    int didx = 0;
    int midx = 0;
    for (UmpireSpecLibMatch match : libIDMatches) {
        if (match.BestHit != null && match.BestHit.UmpireScore > min && match.BestHit.UmpireScore < max) {
            IDObs[idx++] = match.BestHit.UmpireScore;
        }
    }
    for (PeakGroupScore peakGroupScore : decoyModelingList) {
        if (peakGroupScore.UmpireScore > min && peakGroupScore.UmpireScore < max) {
            DecoyObs[didx++] = peakGroupScore.UmpireScore;
        }
    }

    for (UmpireSpecLibMatch match : libTargetMatches) {
        //            for(PeakGroupScore peak : match.TargetHits){
        //                ModelObs[midx++]=peak.UmpireScore;
        //            }
        if (match.BestMS1Hit != null && match.BestMS1Hit.UmpireScore > min
                && match.BestMS1Hit.UmpireScore < max) {
            ModelObs[midx++] = match.BestMS1Hit.UmpireScore;
        }
        if (match.BestMS2Hit != null && match.BestMS2Hit.UmpireScore > min
                && match.BestMS2Hit.UmpireScore < max) {
            ModelObs[midx++] = match.BestMS2Hit.UmpireScore;
        }
    }

    String pngfile = FilenameUtils.getFullPath(Filename) + "/" + FilenameUtils.getBaseName(Filename) + "_"
            + LibID + "_LibMatchModel.png";
    XYSeries model1 = new XYSeries("Incorrect matches");
    XYSeries model2 = new XYSeries("Correct matches");
    XYSeries model3 = new XYSeries("All target hits");

    String modelfile = FilenameUtils.getFullPath(pngfile) + "/" + FilenameUtils.getBaseName(pngfile)
            + "_ModelPoints.txt";
    FileWriter writer = new FileWriter(modelfile);
    writer.write("UScore\tModel\tCorrect\tDecoy\n");

    int NoPoints = 1000;
    double[] model_kde_x = new double[NoPoints];
    float intv = (max - min) / NoPoints;
    PVector point = new PVector(2);
    for (int i = 0; i < NoPoints; i++) {
        point.array[0] = max - i * intv;
        model_kde_x[i] = point.array[0];
        point.array[1] = mmc.EF.density(point, mmc.param[0]) * mmc.weight[0];
        model1.add(point.array[0], point.array[1]);
        point.array[1] = mmc.EF.density(point, mmc.param[1]) * mmc.weight[1];
        model2.add(point.array[0], point.array[1]);

    }

    KernelDensityEstimator kde = new KernelDensityEstimator();
    kde.SetData(ModelObs);
    double[] model_kde_y = kde.Density(model_kde_x);

    for (int i = 0; i < NoPoints; i++) {
        if (model_kde_x[i] > min && model_kde_x[i] < max) {
            point.array[0] = max - i * intv;
            model_kde_x[i] = point.array[0];
            model3.add(model_kde_x[i], model_kde_y[i]);
            writer.write(point.array[0] + "\t" + mmc.EF.density(point, mmc.param[0]) * mmc.weight[0] + "\t"
                    + mmc.EF.density(point, mmc.param[1]) * mmc.weight[1] + "\t" + model_kde_y[i] + "\n");
        }
    }
    writer.close();
    MixtureModelProb = new float[NoPoints + 1][3];
    float positiveaccu = 0f;
    float negativeaccu = 0f;

    MixtureModelProb[0][0] = (float) model2.getMaxX() + Float.MIN_VALUE;
    MixtureModelProb[0][1] = 1f;
    MixtureModelProb[0][2] = 1f;

    for (int i = 1; i < NoPoints + 1; i++) {
        float positiveNumber = model2.getY(NoPoints - i).floatValue();
        float negativeNumber = model1.getY(NoPoints - i).floatValue();
        MixtureModelProb[i][0] = model2.getX(NoPoints - i).floatValue();
        positiveaccu += positiveNumber;
        negativeaccu += negativeNumber;
        MixtureModelProb[i][2] = positiveNumber / (negativeNumber + positiveNumber);
        MixtureModelProb[i][1] = positiveaccu / (negativeaccu + positiveaccu);
    }

    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(model1);
    dataset.addSeries(model2);
    dataset.addSeries(model3);

    HistogramDataset histogramDataset = new HistogramDataset();
    histogramDataset.setType(HistogramType.SCALE_AREA_TO_1);
    histogramDataset.addSeries("ID hits", IDObs, 100);
    histogramDataset.addSeries("Decoy hits", DecoyObs, 100);
    //histogramDataset.addSeries("Model hits", ModelObs, 100);

    JFreeChart chart = ChartFactory.createHistogram(FilenameUtils.getBaseName(pngfile), "Score", "Hits",
            histogramDataset, PlotOrientation.VERTICAL, true, false, false);
    XYPlot plot = chart.getXYPlot();

    NumberAxis domain = (NumberAxis) plot.getDomainAxis();
    domain.setRange(min, max);
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setForegroundAlpha(0.8f);
    chart.setBackgroundPaint(Color.white);

    XYLineAndShapeRenderer render = new XYLineAndShapeRenderer();
    //        render.setSeriesPaint(0, Color.DARK_GRAY);
    //        render.setSeriesPaint(1, Color.DARK_GRAY); 
    //        render.setSeriesPaint(2, Color.GREEN); 
    //        render.setSeriesShape(0, new Ellipse2D.Double(0, 0, 2, 2));
    //        render.setSeriesShape(1, new Ellipse2D.Double(0, 0, 2, 2));
    //        render.setSeriesShape(2, new Ellipse2D.Double(0, 0, 2.5f, 2.5f));
    //        render.setSeriesStroke(1, new BasicStroke(1.0f));
    //        render.setSeriesStroke(0, new BasicStroke(1.0f));
    //        render.setSeriesStroke(2, new BasicStroke(2.0f));
    plot.setDataset(1, dataset);
    plot.setRenderer(1, render);
    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
    try {
        ChartUtilities.saveChartAsPNG(new File(pngfile), chart, 1000, 600);
    } catch (IOException e) {
    }
}