JFreeChart
具有一个称为LineFunction2D(double YIntercept, double Slope)
的类。我可以使用JFreeChart
示例,但不能使用LineFunction2D
。如何将折线图添加到JFreeChart
对象?
LineFunction2D line = new LineFunction2D(.03125, (.125 - .03125));
//missing code goes here
JFreeChart chart = new JFreeChart(Plot plot);
ChartPanel panel = new ChartPanel(chart);
谢谢!
(我正在处理sscce,并将很快发布。)
最佳答案
我认为您正在寻找的代码是对DatasetUtilities.sampleFunction2D
的调用,它将数据集转换为可以添加到绘图中的am XYDataset
private static final double A = 5 / 16d;
private static final double B = 1 / 8d - A;
private double start = 1;
private double end = 10;
private int samples = 4;
private Comparable<String> seriesKey = "Regression";
...
XYPlot plot = new XYPlot(this.data1, xAxis, yAxis, renderer1);
LineFunction2D line = new LineFunction2D(A, B);
XYDataset lineDS = DatasetUtilities.sampleFunction2D(line,start,end,samples,seriesKey );
plot.setDataset(plot.getDatasetCount() + 1, lineDS);
关于java - 在JFreeChart中显示LineFunction2D,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/11894834/