Search code examples
gnuplot

gnuplot set equal distance for ticks on both axes


In gnuplot, I want to plot with x-ticks as [0,1,2,...] and y-ticks as [0,2,4,...], but I also want the tick on both axes to have the same length to make the plot look nicer. I tried

set size ratio 1
set xtics 0,1,6
set ytics 0,2,10

But that does not work. How could I do that?

An example plot is below enter image description here (source: Computational Plasticity, de Souza Neto)


Solution

  • In your example you have 5 units in y-direction and 6 units in x-direction. In order to give them the same visual length you need to set:

    set size ratio 5./6.   # decimal point to avoid gnuplot's integer division
    

    Check help size.

    Script:

    ### set aspect ratio
    reset session
    
    set size ratio 5./6.
    
    set xrange[0:6]
    set xtics 1
    set yrange[0:10]
    set ytics 2
    set grid x,y
    
    plot x**2
    ### end of script
    

    Result:

    enter image description here