Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gnuplot png white on black

Tags:

png

gnuplot

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?

like image 973
Paul Avatar asked Jun 12 '15 22:06

Paul


1 Answers

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
like image 115
Christoph Avatar answered Oct 04 '22 02:10

Christoph