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:
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.
In order to set the legends you must use:
Hope this helps :-)