13

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.

2 Answers 2

18

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
Sign up to request clarification or add additional context in comments.

11 Comments

As a side note, specifying colors by #RRGGBB is probably slightly more system independent. Red = #ff0000, white = #ffffff ... (although red and white should be recognized almost everywhere)
The problem with this is twofold: 1- Apparently I can't make the tics white without making the whole border white? 2- The second line that should set the color for the tic labels (ie: the numbers) does not work. The numbers inherit the color of the tics no matter what color I set there.
set style line 50 ... creates a new linestyle. It uses linetype (lt) 1 which is typically solid, line color (lc) red and linewidth (lw) 2 (which means 2x the normal width). That linestyle is tagged by gnuplot as line-style 50. So, when I use the second line (set border ls 50), it says to plot the border using linestyle 50 (which is the one I just defined).
@Gabriel -- I use gnuplot a lot. It's in my best interest to have lots of other people using it too because then it's development won't stop. Plus, I like being top-dog on the gnuplot tag around here ;-). It makes me feel like I'm an expert in something.
@mgilson Suppose I want to have different colors for y1 and y2. Mission impossible?
|
3

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!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.