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

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

Introduction

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

Prototype

public XYSeries(Comparable key) 

Source Link

Document

Creates a new empty series.

Usage

From source file:jesse.GA_ANN.DataVis.java

JFreeChart createChart()//Here Input MillSecond
{
    total = new XYSeries[10];
    XYSeriescollection = new XYSeriesCollection();
    for (int i = 0; i < 10; i++) {
        total[i] = new XYSeries(i);
        XYSeriescollection.addSeries(total[i]);
    }/*w  ww.  j a va  2  s . c o m*/

    dateaxis = new NumberAxis("Time");
    NumberAxis Conaxis = new NumberAxis("z??");
    dateaxis.setAutoRange(true);
    dateaxis.setLowerMargin(0.0D);
    dateaxis.setUpperMargin(0.0D);
    dateaxis.setTickLabelsVisible(true);
    xylineandshaperenderer = new XYLineAndShapeRenderer(true, false);
    xylineandshaperenderer.setSeriesPaint(0, Color.green);
    xylineandshaperenderer.setSeriesStroke(0, new BasicStroke(1F, 0, 2));
    xylineandshaperenderer.setFillPaint(new Color(30, 30, 220), true);

    Conaxis.setRange(-1, 1);
    Conaxis.setAutoRange(true);
    Conaxis.setAutoRangeIncludesZero(false);

    XYPlot xyplot = new XYPlot(XYSeriescollection, dateaxis, Conaxis, xylineandshaperenderer);
    JFreeChart jfreechart = new JFreeChart("time-z", new Font("Arial", 1, 24), xyplot, true);
    ChartUtilities.applyCurrentTheme(jfreechart);
    ChartPanel chartpanel = new ChartPanel(jfreechart, true);
    chartpanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4),
            BorderFactory.createLineBorder(Color.black)));
    return jfreechart;
}

From source file:edu.pdi2.visual.ViewSignature.java

public ViewSignature(String name, byte[] sign) {
    super();/*  w ww. j  a v a2s  . c o m*/
    XYSeries signature = new XYSeries("Signature");
    for (int i = 0; i < sign.length; i++) {
        signature.add(i, sign[i]);
    }

    JFrame frame = new JFrame();
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(signature);
    JFreeChart signatureG = ChartFactory.createXYLineChart("Signature " + name, "Valorx", "Valory", dataset,
            PlotOrientation.VERTICAL, true, true, false);
    ChartPanel chartpanel = new ChartPanel(signatureG);
    chartpanel.setPreferredSize(new Dimension(390, 290));
    frame.setContentPane(chartpanel);
    frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

    frame.pack();
    frame.setSize(400, 300);
    frame.setVisible(true);
    if (name == " RED")
        frame.setLocation(0, 300);
    else
        frame.setLocation(400, 300);

}

From source file:PerformanceGraph.java

/**
 * Plots the performance graph of the best fitness value so far versus the
 * number of function calls (NFC).// www  .  j  ava 2  s . c  o m
 * 
 * @param bestFitness A linked hashmap mapping the NFC to the best fitness value
 * found so far.
 * @param fitnessFunction The name of the fitness function, used for the title and the
 * name of the file that is saved, e.g. "De Jong".
 */
public static void plot(LinkedHashMap<Integer, Double> bestFitness, String fitnessFunction) {
    /* Create an XYSeries plot */
    XYSeries series = new XYSeries("Best Fitness Value Vs. Number of Function Calls");

    /* Add the NFC and best fitness value data to the series */
    for (Integer NFC : bestFitness.keySet()) {
        /* Jfreechart crashes if double values are too large! */
        if (bestFitness.get(NFC) <= 10E12) {
            series.add(NFC.doubleValue(), bestFitness.get(NFC).doubleValue());
        }
    }

    /* Add the x,y series data to the dataset */
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(series);

    /* Plot the data as an X,Y line chart */
    JFreeChart chart = ChartFactory.createXYLineChart("Best Fitness Value Vs. Number of Function Calls",
            "Number of Function Calls (NFC)", "Best Fitness Value", dataset, PlotOrientation.VERTICAL, false,
            true, false);

    /* Configure the chart settings such as anti-aliasing, background colour */
    chart.setAntiAlias(true);

    XYPlot plot = chart.getXYPlot();

    plot.setBackgroundPaint(Color.WHITE);
    plot.setDomainGridlinesVisible(true);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.black);
    plot.setDomainGridlinePaint(Color.black);

    /* Set the domain range from 0 to NFC */
    NumberAxis domain = (NumberAxis) plot.getDomainAxis();
    domain.setRange(0.0, ControlVariables.MAX_FUNCTION_CALLS.doubleValue());

    /* Logarithmic range axis */
    plot.setRangeAxis(new LogAxis());

    /* Set the thickness and colour of the lines */
    XYItemRenderer renderer = plot.getRenderer();
    BasicStroke thickLine = new BasicStroke(3.0f);
    renderer.setSeriesStroke(0, thickLine);
    renderer.setPaint(Color.BLACK);

    /* Display the plot in a JFrame */
    ChartFrame frame = new ChartFrame(fitnessFunction + " Best Fitness Value", chart);
    frame.setVisible(true);
    frame.setSize(1000, 600);

    /* Save the plot as an image named after fitness function
    try
    {
       ChartUtilities.saveChartAsJPEG(new File("plots/" + fitnessFunction + ".jpg"), chart, 1600, 900);
    }
    catch (IOException e)
    {
       e.printStackTrace();
    }*/
}

From source file:ip.ui.plot.PlotGenerator.java

public void generateErrorChart(List<Double> errors, String plotFileName) throws IOException {
    XYSeries data = new XYSeries("Errors");

    for (int i = 1; i <= errors.size(); ++i) {
        data.add(i, errors.get(i - 1));//from  w  w  w  .ja v a 2  s.  c  o  m
    }

    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(data);
    JFreeChart chart = ChartFactory.createXYLineChart("Squared error", "Epoch number", "Squared Error", dataset,
            PlotOrientation.VERTICAL, false, true, true);

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesLinesVisible(0, false);
    chart.getXYPlot().setRenderer(renderer);

    File XYChart = new File(plotFileName);
    ChartUtilities.saveChartAsJPEG(XYChart, chart, chartWidth, chartHeight);
}

From source file:au.edu.jcu.usb.USBPlotFrame.java

/**
 * Construct a Frame to plot our USB Data.
 *
 * The Frame contains an XY plot (scatter plot), with a single XYSeries.
 *
 * @throws HeadlessException /*from   w ww.j  a  v a2  s . com*/
 */
public USBPlotFrame() throws HeadlessException {
    super("USB Plot");

    XYSeriesCollection xySeriesCollection = new XYSeriesCollection();
    xySeries = new XYSeries("Value");

    xySeriesCollection.addSeries(xySeries);
    ChartPanel chartPanel = constructChart(xySeriesCollection);

    add(chartPanel, BorderLayout.CENTER);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    pack();
    setLocationRelativeTo(null);
}

From source file:serial.LineChart.java

/**
 * Creates a jFreeChart lineChart//from www.  ja  v  a2  s . c  om
 *
 * @param graphName Name of the chart
 * @param xAxisLabel X-Axis Label
 * @param yAxisLabel Y-Axis Label
 * @param bufferSize Max number of data points to display on the graph at a
 * time. Bear in mind that larger values (>30,000) can begin to cause
 * problems with lag.
 */
public LineChart(String graphName, String xAxisLabel, String yAxisLabel, int bufferSize) {
    initComponents();
    defaultSeries = new XYSeries(graphName);
    defaultSeries.setMaximumItemCount(bufferSize);
    defaultDataset = new XYSeriesCollection(defaultSeries);
    defaultChart = ChartFactory.createXYLineChart(graphName, xAxisLabel, yAxisLabel, defaultDataset);
    graph = new ChartPanel(defaultChart);

    this.add(graph, BorderLayout.CENTER);
    graph.setVisible(true);

}

From source file:ejemplo.Ejemplo.java

private XYDataset createDataset() {

    final XYSeries series1 = new XYSeries("First");
    series1.add(1.0, 1.0);/*from  ww  w  .java 2  s. co m*/
    series1.add(2.0, 4.0);
    series1.add(3.0, 3.0);
    series1.add(4.0, 5.0);
    series1.add(5.0, 5.0);
    series1.add(6.0, 7.0);
    series1.add(7.0, 7.0);
    series1.add(8.0, 8.0);

    final XYSeries series2 = new XYSeries("Second");
    series2.add(1.0, 5.0);
    series2.add(2.0, 7.0);
    series2.add(3.0, 6.0);
    series2.add(4.0, 8.0);
    series2.add(5.0, 4.0);
    series2.add(6.0, 4.0);
    series2.add(7.0, 2.0);
    series2.add(8.0, 1.0);

    final XYSeries series3 = new XYSeries("Third");
    series3.add(3.0, 4.0);
    series3.add(4.0, 3.0);
    series3.add(5.0, 2.0);
    series3.add(6.0, 3.0);
    series3.add(7.0, 6.0);
    series3.add(8.0, 3.0);
    series3.add(9.0, 4.0);
    series3.add(10.0, 3.0);

    final XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(series1);
    dataset.addSeries(series2);
    dataset.addSeries(series3);

    return dataset;

}

From source file:scheduler.benchmarker.manager.CreateSimpleSplineChart.java

private XYDataset createDataset() {
    XYSeries cpuTime = new XYSeries(sName + ": CPU");
    XYSeries ioTime = new XYSeries(sName + ": IO");
    double i = 0D;

    for (PlanningResult planningResult : dataSource) {
        cpuTime.add(i, planningResult.getTotalCPUTime());
        ioTime.add(i, planningResult.getTotalIOTime());
        i++;/*from w  ww  .  j a  v a2s  .c om*/
    }

    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(cpuTime);
    dataset.addSeries(ioTime);
    return dataset;
}

From source file:de.cebitec.readXplorer.plotting.CreatePlots.java

public synchronized static ChartPanel createPlot(Map<PersistentFeature, Pair<Double, Double>> data,
        String xName, String yName, XYToolTipGenerator toolTip) {
    XYSeriesCollection normal = new XYSeriesCollection();
    XYSeries nor = new XYSeries("Normal");
    for (Iterator<PersistentFeature> it = data.keySet().iterator(); it.hasNext();) {
        PersistentFeature key = it.next();
        Pair<Double, Double> pair = data.get(key);
        Double X = pair.getFirst();
        Double Y = pair.getSecond();
        nor.add(new PlotDataItem(key, X, Y));
    }/*from ww  w. ja va2s . com*/
    normal.addSeries(nor);
    // create subplot 1...
    final XYItemRenderer renderer1 = new XYShapeRenderer();
    renderer1.setBaseToolTipGenerator(toolTip);
    final NumberAxis domainAxis1 = new NumberAxis(xName);
    final NumberAxis rangeAxis1 = new NumberAxis(yName);
    final XYPlot subplot1 = new XYPlot(normal, domainAxis1, rangeAxis1, renderer1);
    JFreeChart chart = new JFreeChart(subplot1);
    chart.removeLegend();
    ChartPanel panel = new ChartPanel(chart, true, false, true, true, true);
    panel.setInitialDelay(0);
    panel.setMaximumDrawHeight(1080);
    panel.setMaximumDrawWidth(1920);
    panel.setMouseWheelEnabled(true);
    panel.setMouseZoomable(true);
    MouseActions mouseAction = new MouseActions();
    panel.addChartMouseListener(mouseAction);
    ChartPanelOverlay overlay = new ChartPanelOverlay(mouseAction);
    panel.addOverlay(overlay);
    return panel;
}

From source file:metodosnumericos.Graficador.java

public XYSeries series2(String f, String nombre, double xi, double xs) {

    Evaluador func = new Evaluador();
    XYSeries series = new XYSeries(nombre);

    double iter = xi;
    while (iter < xs) {
        double y = func.Evaluador2(f, iter);
        series.add(iter, y);//from   w  w w .j  a  v a2s  .com
        iter = iter + 0.2;
    }
    return series;
}