use strict; use warnings; use Chart::Gnuplot; my @data = (); for my $x (0..100) { for my $y (0..100) { push @data, [$x / 10, $y / 10, ($x**2 - $y**2) / 100]; } push @data, []; # need an empty arrayref between blocks to simulate a newline } my $chart = Chart::Gnuplot->new( output => "test1.png", title => "3D plot from arrays of x, y and z coordinates", xlabel => 'x', ylabel => 'y', ); $chart->set(pm3d => 'map'); $chart->set(palette => 'defined (0 0 0 1, 1 1 1 0, 2 1 0 0)'); $chart->set(contour => 'base'); my $dataSet = Chart::Gnuplot::DataSet->new( points => \@data, ); $chart->plot3d($dataSet);