0

I am trying but not succeeding to replace numeric labels by string labels on a Plot2DPanel display.

Here is a look of my chart using numeric X axis labels:

plot in a JFrame

Here is the code I use:

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

I try to change axis labels by adding this line right before frame.setContentPane(plot);:

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

Where legend is a HashMap<String, Double>, mapping string labels to position on the axis, but this don't change anything to the plot.

I can't figure what I am missing here. Any suggestion would be much appreciated!

Thanks!

kevinad

NB : If this is of any interest, I output this from a gremlin shell with groovy through X11 forwarding.

0

1 Answer 1

0

In order to set the legends you must use:

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

Hope this helps :-)

Sign up to request clarification or add additional context in comments.

1 Comment

Oh it's been a while since I stopped using Plot2DPanel, but the answer is legit ;)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.