gnuplot background color

13,473

Solution 1

My hunch is that you are actually not using the png terminal but instead the pngcairo terminal. This terminal does not support setting a background color.

You can find that out by entering the gnuplot console trying to set the terminal to png with

set terminal png

and then check the output of gnuplot.

In order to use the png terminal you need to build gnuplot with the libgd support.

Solution 2

Ok, I asked for more details, got none, but found the answer myself. I promised to post a hack to fix the ugly white default background in GNUPLOT, so here it is.

On WGNUPLOT, this was just a default tweak to the .ini file . But on GNUPLOT 4.4., running on a Linux box (Fedora/Redhat, in my case), here is what you can do. Lets assume you want a black background, with the graphic borders and text and legend title in yellow, and will let GNUPLOT default pick the colours for the data series you are plotting. Note, make sure to put the "reset" in here, since GNUPLOT remembers all the previous settings - to allow multiple plots to be made with same characteristics, I guess.

Assume you are coding a file called: "testplot.plt" (note, the extension .plt is just an arbitrary choice..)

reset
set border linecolor rgbcolor "yellow"
set key textcolor rgbcolor "yellow"
set title "Test Plot" textcolor rgbcolor "yellow"
set obj 1 rectangle behind from screen 0,0 to screen 1,1
set obj 1 fillstyle solid 1.0 fillcolor rgbcolor "black"
plot sin(x), cos(x), tan(x)

Put the above into a little file, (eg. "testplot.plt"), and use the GNUPLOT load command to load the file, and you should see a black background plot, yellow frame and text, with the legend (what GNUPLOT calls the "key") in yellow text as well. Each of the three trig. function plots should be in a different colour. Oh, and note the Yankee spelling of "colour" - as "color". If you are from the United Kingdom, Canada, Australia, N.Z. etc., you will probably spell it colour and create a bunch of errors and get no plot.. ;)

Hope this is useful...

  • Rus.

Solution 3

Try "set object 1 rectangle from screen 0,0 to screen 1,1 fillcolor rgb"green" behind". For more information vist blog Gnuplot surprising

Share:
13,473
Nick
Author by

Nick

Updated on June 04, 2022

Comments

  • Nick
    Nick almost 2 years

    I used to set the background color similar to this post: How do I change the background color in gnuplot?

    However, with the newest (4.5) version, I am told that this color selection is obsolete. Does anyone know how to do this? I've tried using "set terminal png size 640,296 background #000000", but I'm told that #000000 is not a string of the form #RRGGBB

    I disagree, but the terminal isn't in the mood to argue.

    EDIT: To add to the solution provided below, I never did find away to do it in GNUplot, but rather use the imagemagick command

    convert the.png -fill black -opaque white the.png