#!/usr/bin/perl -w use strict; use Chart::Gnuplot; #=================================== # Advanced Line Chart #=================================== # Prepare data to plot my @x = (1 .. 10); 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 => "advanced_3.png", title => "Line Chart", xlabel => 'Year', ylabel => 'Revenue (M$)', grid => "front", legend => { position => "left", width => 1, height => 1, border => "on", }, plotbg => {color => "white"}, bg => {color => "#EBEBCD"}, imagesize => "0.9, 0.7", ); # Revenue curve of Team A my $lineA = Chart::Gnuplot::DataSet->new( xdata => \@x, ydata => \@y1, title => "Team A", style => "lines", color => "#FF8888", linetype => 'solid', width => 5, ); # Area under curve of Team A my $areaA = Chart::Gnuplot::DataSet->new( xdata => \@x, ydata => \@y1, style => "filledcurve x1", color => "#FFDDDD", ); # Revenue curve of Team B my $lineB = Chart::Gnuplot::DataSet->new( xdata => \@x, ydata => \@y2, title => "Team B", style => "lines", color => "#8888FF", linetype => 'solid', width => 5, ); # Area under curve of Team B my $areaB = Chart::Gnuplot::DataSet->new( xdata => \@x, ydata => \@y2, style => "filledcurve x1", color => "#DDDDFF", ); # Plot $chart->plot2d($areaA, $areaB, $lineA, $lineB);