Skip to content

Instantly share code, notes, and snippets.

@jontonsoup
Created November 15, 2012 21:39
Show Gist options
  • Save jontonsoup/4081490 to your computer and use it in GitHub Desktop.
Save jontonsoup/4081490 to your computer and use it in GitHub Desktop.
elsif ($type eq "plot") {
print header(-type => 'image/png', -expires => '-1h' );
if (!defined($symbol)) {
# $symbol = 'AAPL'; # default
}
open(GNUPLOT,"| gnuplot") or die "Cannot run gnuplot";
print GNUPLOT "set term png\n"; # we want it to produce a PNG
print GNUPLOT "set output\n"; # output the PNG to stdout
print GNUPLOT "plot '-' using 1:2 with linespoints\n"; # feed it data to plot
foreach my $r (@rows) {
$counter = $counter + 1;
if($counter % $mod != 0){
next;
}
print GNUPLOT $r->[0], "\t", $r->[1], "\n";
}
print GNUPLOT "e\n"; # end of data
#
# Here gnuplot will print the image content
#
close(GNUPLOT);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment