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


in reply to Plaintext plot - existing sofware?

Programming on the shoulders of Giants:

use strict; use warnings; use Chart::Gnuplot; my @x = (1..5); my @y = map { rand() } @x; my $dataSet = Chart::Gnuplot::DataSet->new( xdata => \@x, ydata => \@y, title => "Plotting a line from Perl arrays", style => "linespoints", ); # Create chart object and specify the properties of the chart my $chart = Chart::Gnuplot->new( title => "Simple testing", xlabel => "My x-axis label", ylabel => "My y-axis label", terminal => 'dumb', ); # Plot the data set on the chart $chart->plot2d($dataSet);
+ Simple testing + + 0.8 +------------------------------------------------------------ +-----+ | + + + *A* + + + + | 0.7 |-+ Plot***g a**ine from Perl arrays *** +A***-| | **** * + *| 0.6 |-+ *** * + **-| | *** * + * | 0.5 |-+ A* * +* +-| | ** ** * + | 0.4 |-+ ** * ** + +-| | ** * * + | | ** * * + | 0.3 |-+ ** * * + +-| | ** ** * + | 0.2 |-+** * ** + +-| |** * + | 0.1 |-+ A + +-| | + + + + + + + + | 0 +------------------------------------------------------------ +-----+ 1 1.5 2 2.5 3 3.5 4 4.5 + 5 My x-axis label

bw, bliako

Replies are listed 'Best First'.
Re^2: Plaintext plot - existing sofware?
by parv (Parson) on Jul 21, 2021 at 13:57 UTC

    Thanks for showing that gnuplot can produce a text plot. I got overwhelmed by the documentation about multitude of terminals; did not find that myself earlier.

      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