Last updated on June 18, 2020 by Dan Nanni
When you plot many bars along with their labels across x-axis, rotating labels on x-axis helps save space.
To rotate x-axis labels on Gnuplot, you can use the following command.
set xtics rotate {by <angle>} {offset <x,y>}
It will rotate x-axis labels by <angle>
degrees counter-clockwise. Optionally, you can also specify the offset of the labels to adjust their positions. Without any angle parameter, it will by default rotate the labels by 90 degrees.
For example, the following Gnuplot script will produce a bar graph with x-axis labels rotated by 90 degrees.
set terminal png font "Helvetica" 16 set output 'plot.png' set key left set grid y set boxwidth 0.5 set style fill solid 1.0 border -1 set ytics 10 nomirror set yrange [:] set ylabel "Number of Customers" set xtics rotate set bmargin 8 plot 'plot1.dat' using 1:3:xtic(2) notitle with boxes
The next Gnuplot script will create a bar graph with x-axis labels rotated by 45 degrees, and their positions adjusted.
set terminal png font "Helvetica" 16 set output 'plot.png' set key left set grid y set boxwidth 0.5 set style fill solid 1.0 border -1 set ytics 10 nomirror set yrange [:] set ylabel "Number of Customers" set xtics rotate by 45 offset -0.8,-1.8 set bmargin 3 plot 'plot2.dat' using 1:3:xtic(2) notitle with boxes
This website is made possible by minimal ads and your gracious donation via PayPal or credit card
Please note that this article is published by Xmodulo.com under a Creative Commons Attribution-ShareAlike 3.0 Unported License. If you would like to use the whole or any part of this article, you need to cite this web page at Xmodulo.com as the original source.
Xmodulo © 2021 ‒ About ‒ Write for Us ‒ Feed ‒ Powered by DigitalOcean