【问题标题】:Plot2DPanel- Set axis string labelsPlot2DPanel- 设置轴字符串标签
【发布时间】:2013-11-05 09:36:32
【问题描述】:

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

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

这是我使用的代码:

    // 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 是HashMap<String, Double>,将字符串标签映射到轴上的位置,但这不会改变绘图的任何内容。

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

谢谢!

凯维纳德

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

【问题讨论】:

    标签: java groovy plot javaplot


    【解决方案1】:

    为了设置你必须使用的图例:

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

    希望这会有所帮助:-)

    【讨论】:

    • 哦,自从我停止使用 Plot2DPanel 已经有一段时间了,但答案是合法的 ;)
    猜你喜欢
    • 2016-07-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-25
    • 2021-07-16
    相关资源
    最近更新 更多