1

I'm making a Java app, that uses gnuplot. I've already successfuly displayed a graph in JPanel (using JPlot). But I need to get somehow access to commands that JavaPlot gives to gnuplot, or rather I need to display them and directly edit them. And that's the problem I'm stuck on; JavaPlot is too complex library for me and could not find a way how to do that.

I've tried to use GNUPlotParameters in constructor of PlotHandler (code below) but it doesn't seem to work. I was able to get some results with:

class PlotHandler { //my own class that works with the JPlot
    private String gnuplotpath;
    private JavaPlot p;    

  PlotHandler(String path){ 
    this.gnuplotpath=path;
    /*doesn't work
    GNUPlotParameters para = new GNUPlotParameters();          
    para.set("size 900 900");                      
    p = new JavaPlot(para,gnuplotpath,new DefaultTerminal());
    */
    //this does:
    p = new JavaPlot(gnuplotpath);
    p.setTitle("spectrum");
    p.getAxis("x").setLabel("wave length");
    p.getAxis("y").setLabel("absorbance");
  }


  JPlot getGraph(){
    JPlot plot;
    ((AbstractPlot) p.getPlots().get(0)).getPlotStyle().setStyle(Style.LINES);
    plot = new JPlot(p);
    plot.getJavaPlot().plot();
    return plot;
  }   

}

GUI:
...
JPlot plot = plotHandler.getGraph();
System.out.println(plot.getJavaPlot().getCommands()); //this seems to work, but I'm not sure that it would work if I somehow passed some commands thru the GNUPlotParameters.

All in all, I need some methods like

JPlot.getJavaPlot.setCommands(String commands) 

and

String commands = JPlot.getJavaPlot.getCommands()

(getCommands() actually exists, I just cannot tell if it works as I want)

Nick
  • 4,820
  • 18
  • 31
  • 47
Martafix
  • 13
  • 3

0 Answers0