I am having difficulties with getting the grid lines drawn behind my graph and keeping the axis tic marks in front of them, if the data points are near the axis.
Consider these example data, named "t_data":
0 1
1 3
1.8 0
3 5
4 0
5 2
and this script:
reset session
set terminal pdfcairo enhanced color font "Arial,10" size 7.5cm,6cm
set output "t_graph.pdf"
set style line 1 lc rgb "#ff0000" lw 1 pt 5 ps 0.5 pi -1
set pointintervalbox 0.7
unset key
unset title
unset border
set border 3
set xrange [0:5]
set yrange [0:*]
set xtics border nomirror out font "Arial,9"
set ytics border nomirror out font "Arial,9"
set mxtics 5
set mytics 5
set xlabel "x"
set ylabel "y"
set grid xtics mxtics ytics back lt -1 lw 1 lc rgb "#808080", lt -1 lw 1 lc rgb "#808080" dt 2
set tics front
plot "t_data" u 1:2 w lp ls 1
set out
In order to get the tic marks to be in front of the data points at x=0, 2 and 4, I read, e.g., here (gnuplot: fill area curve keeping tics on top) that the set tics front command should come before the plot command, as seen in the script. This however seems to override the option back I gave for the set grid command, i.e., the grid is also drawn on top of my graph (it even says Grid drawn at front when I run show grid after executing the script above).
When I interchange the set grid and the set tics commands, both the grid AND the tics are drawn behind the plot points, which thus obscure the major tic marks partly and the minor tic marks fully (note, that the axis is still drawn on top of the plot points in either case).
Can anyone help me, figure out how to get the grid behind the plot points and the tic marks in front of them (I think this way of plotting graphs makes the most sense, but that's really just IMHO)? I'm also really curious as to the origin of why the set tics and set grid commands seemingly influence each other.
I'm using gnuplot version 5.0 patchlevel 0 on OpenSUSE 42.3 LTS, if that's of importance.