Generating Gnuplot graphs from Perl - and keeping them open

Discussion in 'Perl Misc' started by ryan, May 30, 2007.

  1. ryan

    ryan Guest

    I have a Perl program that successfully executes commands in Gnuplot
    (importing a file and plotting) but I have one problem. I cannot
    figure out how to keep the graph alive. The program executes, flashes
    the graph I need and closes everything. The Gnuplot code is here:

    open(GNU,">$name.p");

    print GNU "set style data lines\n";
    print GNU "set autoscale\n";
    print GNU "unset log\n";
    print GNU "unset label\n";
    print GNU "set xtic auto\n";
    print GNU "set ytic auto\n";
    print GNU "set title \"Random Walk\"\n";
    print GNU "set xlabel \"Iteration\"\n";
    print GNU "set ylabel \"Position\"\n";
    print GNU "plot";
    print GNU " \"$name.dat\" using 1:2 title \'Random Walk\' with
    linespoints $count\n";
    print GNU "replot $mean title \'mean\'\n";

    close DAT;

    #---------------------------------------------------------------
    #--------------------------------------------------------------
    # Attempt to produce graph
    # This part calls gnuplot and executes the commands

    open(GNUPLOT, "|$GNUPlot");


    # The next line means that the following lines should
    # be outputted to the gnuplot program until
    # the words "gnuplot_Commands" is found

    print GNUPLOT << "gnuplot_Commands";
    load '$name.p'
    gnuplot_Commands

    close(GNUPLOT);

    How do I change the code so Gnuplot stays open and the graph is
    displayed for the user?

    Thanks,
    ryan, May 30, 2007
    #1
    1. Advertising

  2. ryan

    Mumia W. Guest

    On 05/30/2007 10:13 AM, ryan wrote:
    > [...]
    > close(GNUPLOT);
    >
    > How do I change the code so Gnuplot stays open and the graph is
    > displayed for the user?
    >


    Use the -persist option to gnuplot.

    > Thanks,
    >


    You're quite welcome.
    Mumia W., May 30, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    4
    Views:
    442
    Nigel Wade
    Mar 10, 2006
  2. Heiko Niedermeyer

    How to create graphs an embed them in GUI?

    Heiko Niedermeyer, Jan 17, 2008, in forum: Python
    Replies:
    7
    Views:
    398
    Heiko Niedermeyer
    Jan 25, 2008
  3. Replies:
    3
    Views:
    342
    Helmut Jarausch
    Jun 13, 2008
  4. Andrea Crotti

    Profiling and generating call graphs

    Andrea Crotti, Jul 29, 2010, in forum: C Programming
    Replies:
    1
    Views:
    422
    Andrea Crotti
    Jul 31, 2010
  5. Po Boy
    Replies:
    12
    Views:
    604
    Po Boy
    May 3, 2004
Loading...

Share This Page