2
votes

I'm trying to have gnuplot put tics but not labels at 0, 1, 2, 3, 4, etc, and then put some text labels but not tics at 0.5, 1.5, 2.5, etc, but can't seem to figure it out. Is that even possible? Any help with that? Thansk!

2

2 Answers

5
votes

Yes, that is possible, but not out of the box. Here is how you can achieve that:

  1. Put the major tics where you want to have the labels, i.e. at 0.5, 1.5 etc.: set xtics ("1st" 0.5, "2nd" 1.5, "3rd" 2.5, "4th" 3.5)
  2. Add one minor tic. Usually this is possible with set mxtics 2, but if you have manually defined xtics, then you must add the minor tics also manually: set for [i=0:4] xtics add (i 1)
  3. Scale the major tics to 0 and the minor tics to the size of the major tics: set xtics scale 0,1

So the following minimal script

set xtics ("1st" 0.5, "2nd" 1.5, "3rd" 2.5, "4th" 3.5)
set for [i=0:4] xtics add (i 1)
set xtics scale 0,1
set xrange [0:4]
plot x

gives (with 4.6.3)

enter image description here

1
votes

Look up "offset" here: http://gnuplot.sourceforge.net/docs_4.2/node295.html
You can tell gnuplot to move your tick labels in any direction you want.
You probably want:

set xtics offset .5, 0 ...