#!/usr/bin/perl -w
use strict;
use Chart::Gnuplot;
# Create the chart object
my $chart = Chart::Gnuplot->new(
    output => "legend_9.png",
    title  => "Format the sample lines",
    legend => {
        sample => {
            length   => 10,
            position => 'left',
            spacing  => 2,
        },
    },
);
# Data set 1
my $data1 = Chart::Gnuplot::DataSet->new(
    func  => "cos(x)",
    title => "cosine",
);
# Data set 2
my $data2 = Chart::Gnuplot::DataSet->new(
    func  => "sin(x)",
    title => "sine",
);
# Data set 3
my $data3 = Chart::Gnuplot::DataSet->new(
    func  => "-0.002 * x**3",
    title => "cubic",
);
# Plot the graph
$chart->plot2d($data1, $data2, $data3);