#!/usr/bin/perl -w use strict; use Chart::Gnuplot; # Data my $numX = 20; my $numY = 20; my @points = (); for (my $i = 0; $i <= $numX; $i++) { my $x = 10*($i/$numX - 0.5); # $x ranges from -5 to +5 for (my $j = 0; $j < $numY; $j++) { my $y = 10*($j/$numY - 0.5); # $y ranges from -5 to +5 my $z = $x*$x - 2*$y*$y; push(@{$points[$i]}, [$x, $y, $z]); } } # Create chart object my $chart = Chart::Gnuplot->new( output => "plot3d_4.png", title => "3D surface plot from array of points", ); # Create dataSet object my $dataSet = Chart::Gnuplot::DataSet->new( points => \@points, style => 'lines', ); # Plot the graph $chart->plot3d($dataSet);