【发布时间】:2023-02-09 22:43:29
【问题描述】:
想使用jmathplot等包来绘制函数图像,但是添加相关包后,抛出一个无法解决的问题。
import javax.swing.*;
import org.math.plot.*;
public class Example {
public static void main(String[] args) {
// define your data
double[] x = { 1, 2, 3, 4, 5, 6 };
double[] y = { 45, 89, 6, 32, 63, 12 };
// create your PlotPanel (you can use it as a JPanel)
Plot2DPanel plot = new Plot2DPanel();
// define the legend position
plot.addLegend("SOUTH");
// add a line plot to the PlotPanel
plot.addLinePlot("my plot", x, y);
// put the PlotPanel in a JFrame like a JPanel
JFrame frame = new JFrame("a plot panel");
frame.setSize(600, 600);
frame.setContentPane(plot);
frame.setVisible(true);
}
}
相关jar文件在GitHub上下载。
【问题讨论】:
-
请检查这个问题的答案:Why should I not upload images of code/data/errors? - 例如,我不能滚动发布的图像以查看整个消息(但我怀疑该错误与加载某些图像有关)
-
我可以重现错误,可能是作者忘记添加一些依赖项或类似内容。甚至 Github 站点上的安装说明也非常不完整:“将 github.com/yannrichet/jmathplot/blob/master/dist/jmathplot.jar 放入您的 java 类路径中“
-
已确认:JAR 文件缺少图标文件夹...也许您尝试从 Github 下载源代码。搜索问题,我们找到了 2015 年的Icons missing from JAR file?!