use strict;
use warnings;
use Chart::Gnuplot;
my @data = (
[0, 0, 10],
[0, 1, 10],
[0, 2, 10],
[],
[1, 0, 10],
[1, 1, 5],
[1, 2, 10],
[],
[2, 0, 10],
[2, 1, 1],
[2, 2, 10],
[],
[3, 0, 10],
[3, 1, 0],
[3, 2, 10],
);
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)');
my $dataSet = Chart::Gnuplot::DataSet->new(
points => \@data,
);
$chart->plot3d($dataSet);
####
Warning: Single isoline (scan) is not enough for a pm3d plot.
Hint: Missing blank lines in the data file? See 'help pm3d' and FAQ.
####
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);