Search code examples
plotformatgnuplotaxisaxis-labels

gnuplot - putting fractions into axis label


I have a log-log plot, counting in powers of 2 up from 1/32.

How can I make the axis labels < 1 be displayed as fractions, rather than decimals (e.g. 1/32 instead of 0.03125)?


Solution

  • You'll have to label the tics individually by hand:

    set xtics ("1/2" .5, "1/4" 0.25, "1/8" .125, ...)
    

    or automatically:

    set logsc x; set xr [1./32:1]
    set xtics ("1",1) # remove all tics and set one initial tic
    do for [i=1:5] {set xtics add (sprintf("1/%.f",2**i) 1./2**i)}
    plot x