Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaPlot (GNUPlot) set legend labels and axis name

The current code i use is:

JavaPlot plotter = new JavaPlot();
plotter.setTitle("Title");

plotter.addPlot(data1);
plotter.addPlot(data1);



plotter.plot();

But I want to be able to set the labels in de legend (now they are: Datafile 1, Datafile2) and also the name of the axis.

I've looked into the documentation of JavaPlot but I haven't found something.

Maybe something with GNUPlotParameters

Thanks!

like image 599
tgoossens Avatar asked Sep 15 '26 11:09

tgoossens


1 Answers

You can set gnuplot parameters with the JavaPlot.set(String, String) method. In your example:

plotter.set("xlabel", "'x'");

Notice that you have to use "'x'" and not just "x".

For the plot title you can use the AbstractPlot.setTitle(String) method.

If you create your plot like this

double[][] data = new double[][] { { 0, 0 }, {1, 1}};
Plot data1 = new DataSetPlot(data);

then you can set the title by casting data1 to AbstractPlot

((AbstractPlot)data1).setTitle("'my title'");

or declare data1 as AbstractPlot right away

double[][] data = new double[][] { { 0, 0 }, {1, 1}};
AbstractPlot data1 = new DataSetPlot(data);
data1.setTitle("'my title'");
like image 59
Dario Seidl Avatar answered Sep 17 '26 02:09

Dario Seidl



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!