gnuplot change all font / text / foreground colors

57 views Asked by At

I'm using gnuplot to generate some graphs with black backgrounds. I'm trying to change all text (or better yet, all foreground elements) to a light color. At the moment I have to manually set a dozen or so different variables. I'm looking for a single command that will do this. So far nothing has worked.

At the moment my gnuplot file looks something like this:

#!/usr/bin/env gnuplot
set terminal svg size 1024,640 background rgb "#000000"
set output 'output.svg'
set key textcolor rgb "#ffffff"
set title "some title"
set xlabel "domain" textcolor rgb "#ffffff"
set ylabel "range" textcolor rgb "#ffffff"
set border linecolor rgb "#ffffff"
set style data lines
plot x**2 title "some function" with lines lc rgb "#ffffff"

Is there any way to consolidate all these "#fffffff"'s into setting a single command? Something like set foreground "#ffffff" or a global set fontcolor "#ffffff" would be nice if it did exist, but I haven't come across anything like this in the gnuplot manual.

1

There are 1 answers

3
theozh On

That's probably not the answer you want to hear, but to my knowledge there is no option to invert all the labels, borders, etc. in one simple command from "light mode" to "dark mode". If there is, I would be happy to learn about it as well.

Well, you could shorten: textcolor to tc, linecolor to lc, rgb "#ffffff" to rgb 0xffffff, with lines to w l and title to ti. You could shorten a few more commands, but then (to my opinion) readability will suffer. I don't know why you would need set style data lines. The example below is using the terminal wxt. Additionally, the example uses and x,y grid, where apparently you cannot set the color directly, but you have to set the color in a linestyle first.

Script:

### set graph to "dark mode"
reset session
set term wxt background rgb 0x000000
set key tc rgb 0xffffff
set title "some title"
set xlabel "domain" tc rgb 0xffffff
set ylabel "range" tc rgb 0xffffff
set border lc rgb 0xffffff
set linestyle 1 lc rgb 0xffffff dt 3
set grid x,y ls 1

plot x**2 w l lc rgb 0xffffff ti "some function"
### end of script

Result:

enter image description here

Well, you could define the textcolor and border color as a variable. If you want to change it you only have to change it at one location. Something like this:

reset session
set term wxt background rgb 0x000000
myColor = 0xffffff
set key tc rgb myColor
set title "some title"
set xlabel "domain" tc rgb myColor
set ylabel "range" tc rgb myColor
set border lc rgb myColor
set linestyle 1 lc rgb myColor dt 3
set grid x,y ls 1

plot x**2 w l lc rgb myColor ti "some function"