Search code examples
gnuplotaxis-labels

Gnuplot - xtics different from grid


The gnuplot grid appears at the same position as the xtics/ytics.

How can I get rid of the tic labels at some (not all) of the tics?

In my case I want to have gridlines at every 0.25 in x and y directions (i.e. at 0|0.25|0.5|...). I only want tic labels in x direction at every 0.5 interval, i.e. at 0|0.5|1|1.5....


Solution

  • There are several possibilities.

    1) Individual tic labels can be replaced with an empty string:

    set xtics 0.25
    set xtics add ("" 0.25, "" 0.75, "" 1.25, "" 1.75)
    

    2) Use the same line type for major and minor tic grid lines. Use minor tics for the additional grid lines:

    set grid lt 2, lt 2     # same linetype for major and minor grid lines
    set grid xtics mxtics   # draw grid for both major and minor tics on x
    set xtics 0.5           # major tics every 0.5
    set mxtics 2            # minor tics at double frequency of major tics
    

    3) Use normal xtics for your plot but use the x2 axis for the grid

    set grid x2tics noxtics     # grid lines for x2 but not x
    set link x2                 # x2 axis uses same range as x axis
    set xtics 0.5               # define tics along x axis
    set x2tics 0.25 format ""   # different tics along x2, no labels