如何使用Perl生成以下gnuplot图? (我需要一个直方图,在每个条形图下我会写出该列与右侧列之间的差异,并使用相同的数据)
问题在于我没有弄清楚如何使用Perl将数字放在条形码下。
这是gnuplot的代码:
reset
set terminal png
set output 'StackOverflow.png'
set style fill solid 1.00
set style histogram clustered gap 1
set style data histograms
set yrange [0:120]
set xtics norangelimit font ",8"
set ytics norangelimit font ",8"
set key font ",8"
set key width -8
xoffset=0.17
yoffset=0.03
plot 'data.dat' using 2:xtic(1) with histogram title "Parameter 1", \
'' u 3 with histogram title "Parameter 2", \
'' u 0:2:4 with labels offset -0.9,0.5 title "", \
'' u 0:3:5 with labels offset 2.0,0.5 title ""
这是Perl代码:
#!/usr/bin/perl -w
use strict;
use Chart::Gnuplot;
my $chart = Chart::Gnuplot->new(
output => 'plotStyle_19.png',
yrange => [0, 120],
bg => {
color => "#c9c9ff",
density => 0.2,
},
);
my @x = qw( A B C D );
my $h1 = Chart::Gnuplot::DataSet->new(
xdata => \@x,
ydata => [99, 97, 97, 95],
title => "1st data set",
color => "purple",
fill => {density => 0.2},
style => "histograms",
);
my $h2 = Chart::Gnuplot::DataSet->new(
xdata => \@x,
ydata => [9, 10, 13, 15],
title => "2nd data set",
color => "dark-green",
fill => {density => 0.2},
style => "histograms",
);
$chart->plot2d($h1, $h2);