Rotating axis labels in Gnuplot

Posted: 27th October 2015 by Tim in Gnuplot
Tags: , , , , , , , ,

In gnuplot, labels on the X and Y axes are aligned horizontally by default, and written over the top of each other if the labels are too long. To fix this, you can rotate the labels using the set xtics rotate [by <angle>] [left|right] command. For example, you can rotate x-axis labels by 60 degrees with the following code:

set xtics rotate by 60 right

We use right alignment here, otherwise the labels run from the base of the graph upwards.

The following full gnuplot code:

set terminal svg
set format x '%+-.6f' # to make the labels longer
set xtics rotate by 60 right
plot cos(x)

will generate this graph:

Your browser doesn’t support SVG, sorry