Is there any way to have gnuplot
color the tic marks in the x and/or y axis? I'm using a background png
file which is quite dark and I'd like the inner tics to show in white over it, not the default black.
Gnuplot can change the color of a line or point based on the values of the data. As usual, there are three ways to do this: explicitly (using the rgb keyword), by indexed lookup (using an integer index), and using a gradient (with the palette keyword).
For terminals that support dot/dash patterns, each default linetype has both a dot-dash pattern and a default color. However, you can override the default color by using the keyword linecolor, abbreviated lc.
The set ytics command controls major (labelled) tics on the y axis. Please see set xtics (p. ) for details.
Fine control of the major (labelled) tics on the x axis is possible with the set xtics command. The tics may be turned off with the unset xtics command, and may be turned on (the default state) with set xtics. Similar commands control the major tics on the y, z, x2 and y2 axes.
The tics
seem to inherit their color from the border
:
set style line 50 lt 1 lc rgb "red" lw 2
set border ls 50
plot sin(x)
The tic labels get their color from the textcolor
option of tics
:
set tics textcolor rgb "red"
(The string "white" should work too, but that wouldn't look very nice in my demonstration since my background is white).
There is no way to change just the tic-color. However, if you want, you can change the tic/border color and then add a new border on top:
set arrow from graph 0,graph 1 to graph 1,graph 1 nohead ls -1 lc rgb "black" front
set arrow from graph 1,graph 1 to graph 1,graph 0 nohead ls -1 lc rgb "black" front
set arrow from graph 1,graph 0 to graph 0,graph 0 nohead ls -1 lc rgb "black" front
set arrow from graph 0,graph 0 to graph 0,graph 1 nohead ls -1 lc rgb "black" front
Whilst this post is quite old, I though I'd offer my 2cents because I have a valid addition to the above.
If you immediately follow the set border command with unset border, then the colour of the tics & their labels remains in the colour you set, and the border just gets removed. For example,
set border linecolor rgb "gray75"
unset border
This way, you can at least change the colour of the tics & their labels (here, off-white), & your background remains dark & untainted by an unsightly (off-white) border, which is what the OP asked for?
Thus, no need to manually redraw the border in the previous answer. Still, the best answer above was useful to me so I will uptick!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With