Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I′m running a java project using gnuplot to generate charts in pdf but I want to save those files in another folder outside my working directory. Is that possible?

I have this for now

Process proc = Runtime.getRuntime().exec("gnuplot test.gp");
        BufferedReader reader =
                new BufferedReader(new InputStreamReader(proc.getInputStream()));

        String line = "";
        while ((line = reader.readLine()) != null) {
            System.out.print(line + "
");
        }

        proc.waitFor();

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
243 views
Welcome To Ask or Share your Answers For Others

1 Answer

In gnuplot console check help command line options. There is the option -e.

You need to have the following argument for exec() in Java.

"gnuplot -e myOutput='<YourPDF>' test.gp"

where you have to replace <YourPDF> with your path. Since I do not know Java, the Java-people have to tell you how you get this done.

A minimal gnuplot script would for example look like the following:

set term pdfcairo
set output myOutput
plot sin(x)   # or whatever
set output

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...