Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to put labels between tics in gnuplot?

Tags:

gnuplot

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!

like image 866
Martin Avatar asked Jan 18 '26 14:01

Martin


1 Answers

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

like image 97
Christoph Avatar answered Jan 21 '26 09:01

Christoph