0

我正在尝试用 Plot2DPanel 显示器上的字符串标签替换数字标签,但没有成功。

这是使用数字 X 轴标签的图表外观:

在 JFrame 中绘图

这是我使用的代码:

    // create your PlotPanel (you can use it as a JPanel)
    Plot2DPanel plot = new Plot2DPanel();

    // add the histogram (50 slices) of x to the PlotPanel
    plot.addHistogramPlot("my plot", x);

    // 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); 

我尝试通过在之前添加此行来更改轴标签frame.setContentPane(plot);

    plot.getAxis(0).setStringMap(legend);

其中 legend 是 a HashMap<String, Double>,将字符串标签映射到轴上的位置,但这不会改变绘图的任何内容。

我无法弄清楚我在这里缺少什么。任何建议将不胜感激!

谢谢!

凯维纳德

注意:如果有任何兴趣,我会通过 X11 转发从具有 groovy 的 gremlin shell 输出它。

4

1 回答 1

0

为了设置图例,您必须使用:

plot.setAxisLabels("Legend Y", "Legend X");

希望这可以帮助 :-)

于 2014-03-14T09:41:05.017 回答