http://qs321.pair.com?node_id=11135287


in reply to Re^2: Plaintext plot - existing sofware?
in thread Plaintext plot - existing sofware?

my phd was a loooong gnuplot script

and here is the time-honored japhy - my first one!

use GD::Simple; use Chart::Gnuplot; my $image = GD::Simple->new(400, 40); $image->trueColor(1); $image->bgcolor('white'); $image->fgcolor('black'); $image->font('courier'); $image->fontsize(20); $image->moveTo(1,21); #$image->string("Just Another Perl Hacker"); $image->string("just another perl hacker"); my $W = $image->width(); my $H = $image->height(); my ($x, $y, $r, @onX, @onY); for ($x=0; $x<$image->width(); $x++) { for ($y=0; $y<$image->height(); + $y++) { $r = $image->getPixel($x,$y); if( $r > 0 ){ push @onY, $x; push @onX, $y; } }} my $dataSet = Chart::Gnuplot::DataSet->new( xdata => \@onX, ydata => \@onY, title => undef, style => "dots", ); # Create chart object and specify the properties of the chart my $chart = Chart::Gnuplot->new( title => undef, xlabel => undef, ylabel => undef, terminal => 'dumb size 40,180', ); # Plot the data set on the chart $chart->plot2d($dataSet);
400 +-----------------------------+ | + + + | | | | | | | | | | | | . . | | .. . . | | .. . . | | .. . . . | | .. .. .. .. .. . | | .. . . | | . . . | | | | . .. .. .. . | | .. . .. . . | | .. .. . . | | .. .. . . | | .. .. .. .. .. | | .. .. .. . | | | 350 |-+ .. . . +-| | .. . . .. . | | .. .. . .. .. . | | .. .. . | | .. .. .. .. .. .. .. . | | . . . | | | | .. .. . .. | | .. . .. . | | .. . . | | .. . . | | .. .. .. .. .. . | | . .. .. | | | | . . | | .. .. .. .. .. . | | .. .. .. . | | .. .. . . | | .. .. .. .. . | | . .. .. | | | | . . | 300 |-+ .. .. .. .. .. . +-| | .. . | | .. . . | | .. .. .. .. .. .. .. . | | .. .. .. .. .. .. .. . | | | | | | | | | | | | | | | | | | . . | | . . | | .. .. .. .. .. .. .. . | | .. .. .. .. .. .. .. . | | . . . | | . . . | | | | .. . | | .. . . | 250 |-+ .. . . . +-| | .. .. .. .. .. . | | .. .. .. .. .. . | | .. . . | | | | . .. .. | | . .. .. .. . | | .. . .. . . | | .. .. . . | | .. . .. .. . | | . .. .. .. .. | | .. . | | .. .. .. . | | .. .. . .. . | | .. . . | | .. . . .| | .. .. . .. .. . .| | .. .. .. .. .. .. .. .| | .. .| | | | | | | 200 |-+ +-| | | | | | | | .. . | | .. . . | | .. . . . | | .. .. .. .. .. . | | .. .. .. .. .. . | | .. . . | | | | . .. .. | | . .. .. .. . | | .. . .. . . | | .. .. . . | | .. . .. .. . | | . .. .. .. .. | | .. . | | . . | | .. .. .. .. .. . | | .. . . . | | .. | 150 |-.. .. .. .. .. .. .. . +-| | .. .. .. .. .. .. .. . | | . . . | | | | .. .. . | | .. . . | | .. . . | | .. .. .. .. .. .. .. . | | .. .. .. .. .. .. . | | .. | | . | | . .. .. .. .. | | .. . .. . | | .. . . | | .. . .. . | | . .. .. .. .. | | . | | . . | | .. .. .. .. .. . | | .. . . . | | .. | | .. . . . | 100 |-+ .. .. .. .. .. . +-| | .. . . | | . . | | .. .. .. .. . | | .. .. .. .. .. . | | .. .. . . | | .. .. . . | | .. .. .. .. . | | . . | | | | | | | | | | | | | | | | | | .. . | | .. . . | | .. . . | | . .. .. .. .. .. .. . | | .. .. .. .. .. .. .. | 50 |-+ .. +-| | | | .. .. . .. .. | | .. .. .. .. .. . | | .. .. . . | | .. . .. . . | | .. .. . . .. . | | . .. . | | . . | | .. .. .. .. .. . | | .. .. .. .. .. . | | .. . .. | | . . | | .. .. .. .. .. . | | .. | | | | .. .. .. .. .. .. . | | .. .. .. .. .. .. .. .. .| | .. .. .| | .. .| | .. .| | + + + | 0 +-----------------------------+ 5 10 15 20 25

bw, bliako