Gnuplot bar chart with Perl: how to put values ββon top of bars
How can the following gnuplot be generated using Perl? (I need a histogram where, under each bar, I will write the difference between this column and the column on the right side with the same data)
The problem is I didn't figure out how to put numbers under the columns using Perl.
This is the gnuplot code:
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 ""
I have currently created the following using Perl:
And this is the Perl code:
#!/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);
+3
source to share
No one has answered this question yet
Check out similar questions: