Search code examples
linuxgnuplot

How to crop top and bottom border around my png with Gnuplot?


I have this script :

set title "df -m command test" font ",14"
set terminal pngcairo truecolor size 1600, 900  background rgb "#eff1f0" font "Arial"
set output "/usr/IBMAHS/htdocs/test.png"
set style line 1 \
    linecolor rgb '#0060ad' \
    linetype 1 linewidth 1 \
    pointtype 7 pointsize 1

set style line 2 \
    linecolor rgb "red" \
    linetype 1 linewidth 1 \
    pointtype 7 pointsize 1

set size ratio 0.2
set offsets 0.5,0.5,0,0.5
set key outside center
set datafile separator ","
set ylabel " MB BLOCK " font ",14" offset -1,0
set xlabel " Date " font ",14" 
set xtics rotate by 45 offset -0.8,-1.8
set format y "%g"
myLabel(n) = sprintf("%g",n)

plot "/usr/IBMAHS/htdocs/TEST.txt" using 2:xtic(1) with linespoints linestyle 1 title "MB used", \
'' using 3:xtic(1) with linespoints linestyle 2 title " Free space ", \
'' using 0:2:(myLabel($2)) w labels offset 0,-0.5 notitle, \
'' using 0:3:(myLabel($3)) w labels offset 0,1 notitle

This script allow to generate this type of graph : enter image description here

But the top and bottom border are so big... I would like to reduce them like that : enter image description here

Can you show me how I can do this ?


Solution

  • You implicitely set the aspect ratio of your output graphic in the second line

    set terminal pngcairo truecolor size 1600, 900 background rgb "#eff1f0" font "Arial"

    Change the 900 to less to get the desired result.