1

I'm having trouble passing GNUplot parameters through JavaPlot. I've been able to use JavaPlot for several different graphs, but I can't seem to get JavaPlot to activate the "polar" setting in GNUPlot.

The GNUPlot command to change to polar mode is simply "set polar". I understand that I probably need to give a .set("polar") command to some PropertyHolder object of the JavaPlot. But which object?

Intuitively, I would try (after creating an image terminal called png):

    GNUPlotParameters params = new GNUPlotParameters();
    params.set("polar");
    GNUPlot p = new GNUPlot(params);
    p.setTerminal(png);
    FunctionPlot func = new FunctionPlot("sin(x)");
    p.addPlot(func);

But this does not work - the build fails on addPlot(). I also tried setting the GNUPlot object itself, but GNUPlot.set() requires a ("keyword","value") argument set, and the command i'd like to sent to GNUPlot is simply "set polar". But doing it this way:

    p.set("polar","");

also results in a build failure. Anyone have a clue how to set a specific GNUPlot parameter (such as polar)?

user4815162342
  • 1,532
  • 2
  • 13
  • 15

2 Answers2

2

Probably you're setting the polar option correctly, but then you must use t as variable for plotting your functions. In an interactive gnuplot session you must use

set polar
plot sin(t)
Christoph
  • 47,569
  • 8
  • 87
  • 187
-1

It turns out that setting the polar keyword SHOULD happen as an attribute of the plot itself, and indeed the variable needs to be t. For completeness, this is what I needed to make it work (with two example functions, one being pre-defined as a function plot):

    JavaPlot p = new JavaPlot();
    p.setTerminal(png);
    p.set("polar","");
    FunctionPlot func = new FunctionPlot("cos(2*t)");
    p.addPlot(func);
    p.addPlot("sin(t)");
    p.setPersist(false);
    p.plot();
user4815162342
  • 1,532
  • 2
  • 13
  • 15