3

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.

mgilson
  • 300,191
  • 65
  • 633
  • 696
loginpassword
  • 307
  • 1
  • 5
  • 14

1 Answers1

5

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 ...

mgilson
  • 300,191
  • 65
  • 633
  • 696
  • Thanks. Your code is exactly I was looking for: xtic(int(strcol(1))%4==1 ? strcol(1):''). Not an automatic overlap detection, but it works perfect too. – loginpassword Oct 25 '12 at 14:46