Search code examples
gnuplot

How to keep the border as a square instead of canvas in gnuplot


I want to make the border a strict square, not a rectangle, here is my picture with the code, how should I modify it? f9 I tried adding the command set terminal pngcairo size 400,400 enhanced square but it gives an error and doesn't make my box square.

set tmargin at screen 0.995;    # top and right usually close to 1
set rmargin at screen 0.995;
set bmargin at screen 0.05;
set lmargin at screen 0.07;

set xr[0:0.24]
set yr[0:0.24]
set xtics border offset   0,0.4 0,0.05,0.2
set ytics border offset   0.8,0 0,0.05,0.2
set xlabel 'B' offset 0,3
set ylabel 'C' offset 9,0

set key at 0.22,0.1 width 1 maxrows 4

plot '-' w p ps 2 pt 11 lc 8 title "D",\
     '-' w p ps 2 pt 7 lc 8 title "A",\
     '-' w p ps 2 pt 9 lc 8 title "A", \
     '-' w p ps 2 pt 13 lc 8 title "A",\
     '-' w p ps 2 pt 10 lc 8 title "A",\
     '-' w p ps 2 pt 6 lc 8 title "A",\
     '-' w p ps 2 pt 8 lc 8 title "A",\
     '-' w p ps 2 pt 12 lc 8 title "A",\
     x dashtype 2 lc 8 lw 3 notitle

0.208555 0.204212
e
0.108604 0.107899
e
0.055720 0.055651
e
0.037514 0.037498
e
0.208555 0.230125
e
0.108604 0.115062
e
0.055720 0.057531
e
0.037514 0.038354
e

f10 f11


Solution

  • Check the manual and read help size.

    Syntax: 
    
          set size {{no}square | ratio <r> | noratio} {<xscale>,<yscale>}
    

    If you want the graph area (not the canvas) to be a square add a line:

    set size square
    

    If you want the x- and y-axes the same scale, i.e. y=x will appear as a 45° line (but the graph area will not necessarily be a square), add:

    set size ratio -1