#!/usr/bin/perl -w
use strict;
use Chart::Gnuplot;
# Prepare data to plot
my @x = (1 .. 5);
my (@y1, @y2) = ();
for (my $i = 0; $i < @x; $i++)
{
my $y1 = sqrt($x[$i]) + (rand()-0.5) + 1;
my $y2 = sqrt($x[$i]) + (rand()-0.5);
push(@y1, $y1);
push(@y2, $y2);
}
# Chart object
my $chart = Chart::Gnuplot->new(
output => "area.png",
imagesize => "0.45,0.45",
);
# DataSet object of Area A
my $areaA = Chart::Gnuplot::DataSet->new(
xdata => \@x,
ydata => \@y1,
style => "filledcurve x1",
color => "#EEBBBB",
);
# DataSet object of Area B
my $areaB = Chart::Gnuplot::DataSet->new(
xdata => \@x,
ydata => \@y2,
style => "filledcurve x1",
color => "#BBEEBB",
);
# Plot the graph
$chart->plot2d($areaA, $areaB);