Gnuplotting

Create scientific plots using gnuplot

July 27th, 2010 | 1 Comment

In the introduction I have set the xtics labels manually to use a multiple of π:

set xtics ('-2π' -2*pi, '-π' -pi, 0, 'π' pi, '2π' 2*pi)

But there is an easier way to achieve the same. First we tell Gnuplot to place the tics at multiplies of π. And then the trick: with the set format option we can tell Gnuplot to use multiple of π too:

set xtics pi
set format x '%.0Pπ'

In the same way we can place tics without any label by applying:

set format x ''

1 Comment

  1. Wolter Hellmund says:

    Perhaps a common pitfall would be to use n/m*pi as tick values where n and m are integers; don’t do it because n/m = 0 so your ticks won’t work. Use n*pi/m instead, or either n or m as a double.