I'm using Chart::Gnuplot in Perl and am producing a 3D plot (plot3d), which works fine. I'm trying to change the default colour palette and I know its done with "set palette" functions but am struggling to find the equivalent command in Perl. I'd like to define specific colours for specific values, which will be something like the code below, but it returns an error.
my $chart = Chart::Gnuplot->new(
... ,
palette => {defined => ('0 "#000090",
1 "#000fff",
2 "#0090ff",
3 "#0fffee",
4 "#90ff70",
5 "#ffee00",
6 "#ff7000",
7 "#ee0000",
8 "#7f0000"')},
... ,
);
There should also be an alternative command to define default palettes such as "rainbow" or "heat1" etc., but I also don't know how to do this in Perl.
Thanks.
Options, which aren't explicitely handled, expect a string and are converted simply to set statements.
Taking the example from http://search.cpan.org/~kwmak/Chart-Gnuplot-0.21/lib/Chart/Gnuplot.pm#Chart_Options_Not_Mentioned_Above, which says, that the expression
$chart = Chart::Gnuplot->new(
...
foo => "FOO",
);
generates the gnuplot statement
set foo FOO
Consequently, your palette definition must be
my $chart = Chart::Gnuplot->new(
...,
palette => 'defined (0 "#000090", \\
1 "#000fff", \\
2 "#0090ff", \\
3 "#0fffee", \\
4 "#90ff70", \\
5 "#ffee00", \\
6 "#ff7000", \\
7 "#ee0000", \\
8 "#7f0000")',
);
The \\
is necessary in this case to keep a single backslash in the gnuplot script which allows the palette definition to go over several lines.