'How to prevent xtick labels too cramped?
With xticks automatically generated by gnuplot we find too often that the labels are too tight / cramped together as shown in this snapshot. How can we fix this issue?

Solution 1:[1]
This is a very crude workaround. The idea is telling how many (approximate) number of tick labels one wants, and have gnuplot "translate" that into a suitable tick spacing according to the whole plotting range.
I am posting what I am using now, and it works reasonably well. It takes xmin=0. You could guess the way it works and tune it.
# Get/print stats about input data, ...
stats "output.csv" using 2:5 nooutput
# ... and use them for setting the number of tick labels for x axes, to avoid overlap
#tmin = STATS_min_x
tmin = 0
tmax = STATS_max_x
nxtics = 5 # Tune this
# Do not count 0 as a tick
nxtics = nxtics - 1
# Shift numbers to the range [1,10)
ttic1 = tmax / nxtics
nshift_digits = -floor(log10(ttic1))
shift = 10.0**nshift_digits
tmax_shift = tmax * shift
ttic1_shift = ttic1 * shift
# ttic1_shift should be between [1,10)
# Use (arbitrary) specified tick spacing (here at 1, 2, 5 in the first significant digit, but one could use others, including 2.5, e.g.), which better matches the data range and selected number of tick labels. Note that the number of tick labels would not be strictly maintained.
# Tune these numbers
ttic_shift = 1.0
if (ttic1_shift < 1.3) {
ttic_shift = 1.0
} else { if (ttic1_shift < 3.0) {
ttic_shift = 2.0
} else { if (ttic1_shift < 7.0) {
ttic_shift = 5.0
} else {
ttic_shift = 10.0
} } }
ttic = ttic_shift / shift
print "ttic=", ttic
PS: I could not have this working, although I did not try "hard". I guess that solution might work for a single plotted dataset, but not sure it would work for more than one.
Solution 2:[2]
If they aren't too cramped, you can rotate them 90 degrees i.e.
set xtics rotate by 90
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | sancho.s ReinstateMonicaCellio |
| Solution 2 | Joshua Gee |
