0
votes

Say we got this data 'file.dat':

0.1 2
0.5 1
0.7 3
1.3 23
1.4 20
2.7 2
2.3 6
5.3 50
5.2 50

I wish to plot this as follows:

  • 2D plot (lines is fine), like normal.
  • Except: xtics label shows the following names instead: "small", "medium", "big" marked exactly at x values 0, 3 and 5, respectively.

Q: How to achieve this?

Permissible actions:

  • I can modify existing or create new 'file.dat' files.
  • I can modify gnuplot commands.
1

1 Answers

2
votes
set xtics ("small" 0, "medium" 3, "big" 5)
plot 'file.dat' with lines lw 2 lc rgb "black"

should work.

For more information type help xtics:

The explicit ("" , ...) form allows arbitrary tic positions or non-numeric tic labels. In this form, the tics do not need to be listed in numerical order. Each tic has a position, optionally with a label. Note that the label is a string enclosed by quotes. It may be a constant string, such as "hello", may contain formatting information for converting the position into its label, such as "%3f clients", or may be empty, "". See set format for more information. If no string is given, the default label (numerical) is used.

An explicit tic mark has a third parameter, the level. The default is level 0, a major tic. Level 1 generates a minor tic. Labels are never printed for minor tics. Major and minor tics may be auto-generated by the program or specified explicitly by the user. Tics with level 2 and higher must be explicitly specified by the user, and take priority over auto-generated tics. The size of tics marks at each level is controlled by the command set tics scale.

Examples:

   set xtics ("low" 0, "medium" 50, "high" 100)
   set xtics (1,2,4,8,16,32,64,128,256,512,1024)
   set ytics ("bottom" 0, "" 10, "top" 20)
   set ytics ("bottom" 0, "" 10 1, "top" 20)