#!/usr/bin/perl -w
use strict;
use Chart::Gnuplot;
# Data in array of points
my @points = ();
for (my $x = -5; $x < 5; $x += 0.02)
{
my $y = sin($x*3);
my $z = cos($x*3);
push(@points, [$x, $y, $z]);
}
# Create chart object
my $chart = Chart::Gnuplot->new(
output => "plot3d_2.png",
title => "3D plot from array of points",
xlabel => 'x',
ylabel => 'y',
zlabel => 'z',
);
# Create dataSet object
my $dataSet = Chart::Gnuplot::DataSet->new(
points => \@points,
style => 'lines',
);
# Plot the graph
$chart->plot3d($dataSet);