Question: Good evening:

I am collecting data on number of function evaluations to be graphed using the two methods below. The first runs Romberg integration for a given n and m, n<=m. Within that method a global counter is incremented during each evaluation, and I want to graph the number of evaluations for a given R(n,m). The second receives the dataset and graphs it.

```
public static XYSeriesCollection functionDataCollecter(){
    counter = 0;

    //a single line on a chart
    XYSeries series; 

    //a collection of series
    XYSeriesCollection dataset = new XYSeriesCollection(); 

    for(int i=0;i<3;i++){
        //initiate new series
        series = new XYSeries("data");
        for(int k = i; k<9;k++){
            R_nm(k,i,0,(Math.PI)/2);
            series.add(k, counter);
        }
        //add series to dataset
        dataset.addSeries(series);   
    }

    return dataset;
}

public static void seriesPlotter(XYSeriesCollection dataset) {

    XYPlot myPlot = new XYPlot("m=2", "Math 521", "m<=n<9", "log_10(F(n,m))", dataset);
    myPlot.pack();
    myPlot.setVisible(true);

}

```

I am running into a problem. It seems that I have to name each series in the dataset uniquely. I get the error: "This dataset already contains a series with the key data at org.jfree.data.xy.XYSeriesCollection.addSeries(XYSeriesCollection.java:159)

I can't seem to find a simple way to append or increment my series variable names. Arrays confuse the crap out of me, and they are the only option I have found mentioned in my online searches. 

I appreciate simple suggestions, as I am not a programmer and just learned the difference between a class and an object. I say this to help you frame your suggestions, if you care to help me out. Thanks in advance.

Answer: 
Ok, I just figured this out, and it was much more simple than I thought. The error message is not referring to some requirement for a unique declared name for each series. It is referring to the String argument: 

```
series = new XYSeries("data");

```

Just update the argument in the loop, and that was enough to get three multi-colored plots:

```
series = new XYSeries("data"+Integer.toString(i));

```

I hope this helps someone down the road!
As shown [here](http://www.jfree.org/jfreechart/api/javadoc/src-html/org/jfree/data/xy/XYSeriesCollection.html#line.145), the collection's `addSeries()` method uses the name of the incoming `XYSeries` as the key. You can add multiple series to the collection as long as the names are unique. In this [example](https://stackoverflow.com/a/7208723/230513), two series are named `"Random"` and `"Added"`; the latter series gets updated dynamically when you click the `Add` button.

[![image](https://i.stack.imgur.com/WWofa.png)](https://i.stack.imgur.com/WWofa.png)

As your program evolves,

* You can update the chart as a value in a `JSpinner` changes, as shown [here](https://stackoverflow.com/a/20266619/230513).

[![image](https://i.stack.imgur.com/nnEje.png)](https://i.stack.imgur.com/nnEje.png)

* You can animate the progress of a calculation using a worker thread, as shown [here](https://stackoverflow.com/a/13205322/230513).

[![image](https://i.stack.imgur.com/mUP4r.png)](https://i.stack.imgur.com/mUP4r.png)