gnuplot png white on black

6.8k views Asked by At

In gnuplot-4.2.6 I can produce a nice white on black image using

set term png medium x000000 xffffff
set output 'file.png'
plot x

This produces a png file with a black background and white axes, axis labels, titles, legend text, etc.

The new gnuplot-5.0.1 complains about the above 'set term' command saying "obsolete color option". The closest I can come to getting an image which is white on black is to set the background to black with

set term png medium background '#ffffff'
set output 'file.png'
plot x

but this just sets the background to black without setting the axes, axis labels etc. to white.

Does anyone know how I can get white on black png images in the latest version of gnuplot?

1

There are 1 answers

2
Christoph On

These color options for the png terminal were removed with version 4.6. The log says about this: This mechanism is totally obsolete except for setting the background color.

Since version 4.6.0 you can (but also must) set the linecolor and textcolor of every part explicitely:

set terminal pngcairo background rgb 'black'
set xlabel 'ylabel' tc rgb 'white'
set ylabel 'xlabel' tc rgb 'white'
set border lc rgb 'white'
set key tc rgb 'white'

set linetype 1 lc rgb 'white'
set output 'bw.png'
plot x lc 1, x**2 lc 1

enter image description here

If you only need those settings for some pictures you could move several parts to some kind of config file `black-and-white.gp' with the content

set macros
bg = 'background rgb "black"'
white = 'textcolor rgb "white"'
set xlabel @white
set ylabel @white
set linetype 11 lc rgb 'white'
set border lc 11
set key @white

In the actual plotting file you use it like

load 'black-and-white.gp'
set terminal pngcairo @bg
set xlabel 'xlabel'
set ylabel 'ylabel'

set output 'bw.png'
plot x lc 11, x**2 lc 11