这是我学习Java的第一个月,对于我的愚蠢问题,我提前道歉。我正在尝试使用Jfreechart制作一个简单的程序。我想在散点图上显示我的二维数组。
这里是代码:
package myappthatusesjfreechart;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartFrame;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.general.DefaultPieDataset;
public class MyAppThatUsesJFreeChart {
public static void main(String[] args) {
// create a dataset...
int[][] a2 = new int[10][5];
// print array in rectangular form
for (int r = 0; r < a2.length; r++) {
for (int c = 0; c < a2[r].length; c++) {
System.out.print(" " + a2[r][c]);
}
System.out.println("");
}
// create a chart...
JFreeChart chart = ChartFactory.createScatterPlot(
"Scatter Plot", // chart title
"X", // x axis label
"Y", // y axis label
a2, // data ***-----PROBLEM------***
PlotOrientation.VERTICAL,
true, // include legend
true, // tooltips
false // urls
);
// create and display a frame...
ChartFrame frame = new ChartFrame("First", chart);
frame.pack();
frame.setVisible(true);
}
}
;ChartFactory.createScatterPlot; 不允许我传递二维数组,我想问是否有任何方法可以做到这一点。
DefaultDrawingSupplier
和这个答案。您可以点击左边的空白复选框来接受此答案;有关详细信息,请参见[faq]。 - trashgod