Gnuplot x tic labels overlap

2019-07-20 20:44发布

问题:

I am drawing a gnuplot chart from datafile with such format:

01 value_1_1 value_2_1
02 value_1_1 value_2_1
...
01 value_1_n value_2_n

using that command:

plot "action.dat" using 2:xtic(1) with boxes ls 1 title "First title",\
     "action.dat" using 3:xtic(1) with boxes ls 2 title "Second title";

X tic labels are loaded from the first column. When terminal is too small, labels start to overlap. How can I hide x tic label if it overlaps previous label? Or, at least, how can I draw only n-th label?

I've tried to do something like that

set xtics 10 rotate by -90

but failed.

回答1:

To (effectively) plot every nth label, you can use something like:

plot "action.dat" using 2:xtic(int($0)%3==1 ? strcol(1):'') with boxes ls 1 title "First title"

This will actually plot every label, but the ones that aren't the n'th label will just be plotted as empty strings ...