0

I try to plot using JavaPlot a particular graph in a java project (I use eclipse).

Now, I create the module for plotting as follow:

public void createPlot(){
    JavaPlot p = new JavaPlot();
    p.set("key", "rmargin");
    p.set("key title","'OBJECTS INSIDE:'");
    p.set("size", "square");
    p.set("xlabel", "'x'");
    p.set("ylabel", "'y'");
    p.set("title", "'TITLE'");
    p.addPlot(positionData); 
    p.plot();   
}

And the program work very good but I like to put inside this plot some upgrading:

  1. I like to put inside the grid but if I write: p.set("grid"); I receive error;
  2. I like to change the pointsize and point-type of the plot.

I understand, for the moment, that using p.set("",""); I need to specify what to set (xlabel, ylabel, size...) and how to set (x,y,square...) but how about more complex commands such that in point 1. and 2. of this question?

  • 1
    These seem to be just GNUPlot commands. Doesn't something like `p.set("grid", "back ls 12");` work? – Marco13 Jul 06 '14 at 17:32
  • @Marco13 Yes it work fine for grid. So Do you think I can use the same to change the type and size for the points? – Panichi Pattumeros PapaCastoro Jul 07 '14 at 10:49
  • 1
    Sorry, I'm neither familiar with GNUPlot nor with JavaPlot. There seem to be dedicated properties for this, e.g. http://javaplot.panayotis.com/doc/com/panayotis/gnuplot/style/PlotStyle.html#setPointSize%28int%29 , but maybe someone else can give a more profound answer (maybe including an example) here. – Marco13 Jul 07 '14 at 12:15

1 Answers1

0

To change the point size and point type of the plot, you can explicitly define a JavaPlot style. Point type is set as an integer, so you may have to guess and check to get what you are looking for (the shape represented by each integer is set by the terminal type; for example style 13 in a png terminal gives diamond points).

PlotStyle newStyle = new PlotStyle(Style.POINTS);
newStyle.setPointType(13);
newStyle.setPointSize(4);

Then you need to apply the style to your data object:

positionData.setPlotStyle(newStyle)

then finally the commands to initialize and edit your plot parameters:

JavaPlot p = new JavaPlot();
p.set("key", "rmargin");
p.set("key title","'OBJECTS INSIDE:'");
p.set("size", "square");
p.set("xlabel", "'x'");
p.set("ylabel", "'y'");
p.set("title", "'TITLE'");
p.addPlot(positionData); 
p.plot();  

http://javaplot.panayotis.com/doc/index.html

Hopefully someone else can explain how to display a grid; I'm interested in how to do that too.

user4815162342
  • 1,532
  • 2
  • 13
  • 15
  • Hi thanks for the answer I try to do what You guess but I have a problem when I try to apply the style to the data. I use eclipse that give me the follow error message: "Cannot invoke SetPlotStyle(PlotStyle) on the array type double[][]" What kind of error I make? – Panichi Pattumeros PapaCastoro Aug 08 '14 at 22:21
  • 1
    ahh you need to define your array as a DataSetPlot first, then you can apply the style: DataSetPlot newSet= new DataSetPlot(values); newSet.setPlotStyle(styleDeleted); – user4815162342 Aug 13 '14 at 16:56