JFreeChart 多系列问题
JFreeChart multiple series issue
晚上好:
我正在收集有关要使用以下两种方法绘制的函数评估数量的数据。第一个对给定的 n 和 m,n<=m,运行 Romberg 积分。在该方法中,全局计数器在每次评估期间递增,我想绘制给定 R(n,m) 的评估次数。第二个接收数据集并绘制它。
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);
}
我 运行 遇到了问题。看来我必须唯一地命名数据集中的每个系列。我收到错误消息:“此数据集已包含一系列关键数据位于 org.jfree.data.xy.XYSeriesCollection.addSeries(XYSeriesCollection.java:159)
我似乎找不到一种简单的方法来附加或递增我的系列变量名称。数组让我很困惑,它们是我在网上搜索中发现的唯一选项。
我很欣赏简单的建议,因为我不是程序员,只是了解 class 和对象之间的区别。如果您愿意帮助我,我这么说是为了帮助您提出建议。提前致谢。
如图here, 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,两个系列分别命名为"Random"
和"Added"
;当您单击 添加 按钮时,后一个系列会动态更新。
随着程序的发展,
- 您可以将图表更新为
JSpinner
更改中的值,如图 here。
- 您可以使用工作线程为计算进度设置动画,如图所示here。
好的,我刚刚弄明白了,它比我想象的要简单得多。错误消息不是指对每个系列的唯一声明名称的某些要求。它指的是字符串参数:
series = new XYSeries("data");
只需更新循环中的参数,就足以得到三个多色图:
series = new XYSeries("data"+Integer.toString(i));
我希望这对以后的人有所帮助!
晚上好:
我正在收集有关要使用以下两种方法绘制的函数评估数量的数据。第一个对给定的 n 和 m,n<=m,运行 Romberg 积分。在该方法中,全局计数器在每次评估期间递增,我想绘制给定 R(n,m) 的评估次数。第二个接收数据集并绘制它。
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);
}
我 运行 遇到了问题。看来我必须唯一地命名数据集中的每个系列。我收到错误消息:“此数据集已包含一系列关键数据位于 org.jfree.data.xy.XYSeriesCollection.addSeries(XYSeriesCollection.java:159)
我似乎找不到一种简单的方法来附加或递增我的系列变量名称。数组让我很困惑,它们是我在网上搜索中发现的唯一选项。
我很欣赏简单的建议,因为我不是程序员,只是了解 class 和对象之间的区别。如果您愿意帮助我,我这么说是为了帮助您提出建议。提前致谢。
如图here, 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,两个系列分别命名为"Random"
和"Added"
;当您单击 添加 按钮时,后一个系列会动态更新。
随着程序的发展,
- 您可以将图表更新为
JSpinner
更改中的值,如图 here。
- 您可以使用工作线程为计算进度设置动画,如图所示here。
好的,我刚刚弄明白了,它比我想象的要简单得多。错误消息不是指对每个系列的唯一声明名称的某些要求。它指的是字符串参数:
series = new XYSeries("data");
只需更新循环中的参数,就足以得到三个多色图:
series = new XYSeries("data"+Integer.toString(i));
我希望这对以后的人有所帮助!