By default gnuplot will produce graphes with white background color. We can change it by drawing a colored rectangle at the lowest layer:
set object <index_number> rectangle \
from screen 0,0 to screen 1,1 fillcolor rgb"<rgb-color>" behind
In this command line, <index_number> is used to mark the rectangle object, if we want to change the background color later it will be usefull, "from screen 0,0 to screen 1,1" means the rectangle is as large as the whole picture, <rgb-color> is the background color and "behind" put the rectangle behind all other elements of the picture,i.e., the lowest layer.
Now let's have a look at an example script which produce two graphes with pink and light green background color respectively.
reset #reset gnuplot options
set term png font ",22" linewidth 3 #set terminal to png with fontsize=22,linewidth=3
set xlabel "x" #set xlable and ylabel
set ylabel "y=sin(x)"
#set a pink(#ffcccc) background color
set object 1 rectangle from screen 0,0 to screen 1,1 fillcolor rgb"#ffcccc" behind
set output "pink.png"
plot sin(x) with lines linecolor rgb"green" notitle
#set a light green(#ccffcc) background color
set object 1 rectangle from screen 0,0 to screen 1,1 fillcolor rgb"#ccffcc" behind
set output "lightgreen.png"
plot sin(x) with lines linecolor rgb"red" notitle
And pink.png and lightgreen.png are shown below:
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjY2dibwpK3BlkV4QSiUzeeioS4sfiqyvTVKVc9At0Fhwi2oZcuKhxiZMfhWjKT9-NSihF8ALzsI5SVGj-KONXyz_pA2bmeqCLjHBSjEMhYblwfEbSd-gtSMX1i4KEd579XsBLXr-o5XXKG/s320/pink.png) |
Pink background color |
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhN4VaEXX7M9IlVZXKR5Hz3J4UuvqXiTuJbns0D-luhFNkOKfOzGlLaybgw5QcUqs_QXwtIAFim8XWKF4ZX-frmNOoT7YwaZG7jAHNXIL2p76tGcQBXr0Bo_YZ_2ushtbzLen8rQxZiycQ1/s320/lightgreen.png) |
Light green background color |
I'd like to reverse black and white on my plot, so this is a neat trick for the background. Do you know how one would then change the axis and text colour to white? I'm using epslatex terminal so I know that the labels can be changed simply by adding "\color{white} ..." before the text but I'm stumped as to how to change the rest.
ReplyDeleteThe color of lines and text are controled by parameter "linecolor"("lc" in short) and "textcolor"("tc" in short). For example, "plot sin(x) w l lc rgb"white" " will plot a white line and "set xtics tc rgb"white" " will change the text color of xtics to be white.
DeleteGnuplot Surprising: Gnuplot Simple Background Color >>>>> Download Now
Delete>>>>> Download Full
Gnuplot Surprising: Gnuplot Simple Background Color >>>>> Download LINK
>>>>> Download Now
Gnuplot Surprising: Gnuplot Simple Background Color >>>>> Download Full
>>>>> Download LINK Bz
I have a multiplot graph and I'd like to use your method to set a transparent background. How can I get this?
ReplyDeleteIf I simple use your method, I get just one plot and background set up with the fixed color.
I'm using python and svg output files.
To set a transparent background, you should use command "set style fill transparent". And using suitable coordinates in command "set object 1 rectangle from screen 0,0 to screen 1,1 fillcolor rgb"#ccffcc" behind", you can set the background color of defined area.
ReplyDeleteGnuplot Surprising: Gnuplot Simple Background Color >>>>> Download Now
ReplyDelete>>>>> Download Full
Gnuplot Surprising: Gnuplot Simple Background Color >>>>> Download LINK
>>>>> Download Now
Gnuplot Surprising: Gnuplot Simple Background Color >>>>> Download Full
>>>>> Download LINK z5