Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gnuplot background color

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
like image 938
Nick Avatar asked Dec 05 '22 20:12

Nick


2 Answers

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.
like image 77
Russel Future Avatar answered Mar 06 '23 07:03

Russel Future


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

like image 32
hsxz Avatar answered Mar 06 '23 08:03

hsxz