How to set the color of the background in multiple plot in gnuplot? I tried the following script:
reset
set encoding iso_8859_1
set terminal pngcairo size 1400,800 font "Serif CMU,15" enhanced
set output "figure.png"
Row1 = "set tmargin screen 0.92; set bmargin screen 0.40" # Top and bottom margins
Row2 = "set tmargin screen 0.40; set bmargin screen 0.20"
Col1 = "set lmargin screen 0.10; set rmargin screen 0.50" # Left and right margins
Col2 = "set lmargin screen 0.50; set rmargin screen 0.88"
# Multiplot option with main title
set multiplot layout 2,2 rowsfirst
@Row1; @Col1 # Calling the macros
set object 1 rectangle from screen 0,0 to screen 1,1 behind fillcolor rgb '#F6DEBE' fillstyle solid noborder
plot 'blue.txt'
@Row1; @Col2
set object 1 rectangle from screen 0,0 to screen 1,1 behind fillcolor rgb '#F6DEBE' fillstyle solid noborder
plot 'blue.txt'
@Row2; @Col1
set object 1 rectangle from screen 0,0 to screen 1,1 behind fillcolor rgb '#F6DEBE' fillstyle solid noborder
plot 'blue.txt'
@Row2; @Col2
set object 1 rectangle from screen 0,0 to screen 1,1 behind fillcolor rgb '#F6DEBE' fillstyle solid noborder
plot 'blue.txt'
I also tried to set unset object 1 after each plot.
I obtained:
Welcome to StackOverflow! Have you checked help pngcairo
?
Syntax:
set term pngcairo {{no}enhanced} {mono|color} {{no}transparent} {{no}crop} {background <rgbcolor>
So, something like the following should do the job, unless you have some special wishes.
set term pngcairo background 0xf6debe
Addition:
If you want to set different backgrounds for the graphs you can either set a rectangle behind the full graph or part of the screen.
However, although there should be the option noborder
, I haven't managed to plot the rectangles without border. I don't know what I am missing.
Code: (colored graph background)
### different colored backgrounds for each graph
reset session
set multiplot layout 2,2
set grid x,y
set obj 1 rect from graph 0,0 to graph 1,1 fc rgb 0xffdddd behind
plot x
set obj 1 rect from graph 0,0 to graph 1,1 fc rgb 0xddffdd behind
plot x**2
set obj 1 rect from graph 0,0 to graph 1,1 fc rgb 0xddddff behind
plot cos(x)
set obj 1 rect from graph 0,0 to graph 1,1 fc rgb 0xffffdd behind
plot sin(x)/x
unset multiplot
### end of code
Result:
Code: (colored backgrounds for part of canvas/screen)
### colored backgrounds in multiplot
reset session
set multiplot layout 2,2
set obj 1 rect from screen 0.0,0.5 to screen 0.5,1.0 fc rgb 0xffeeee behind
plot x
set obj 1 rect from screen 0.5,0.5 to screen 1.0,1.0 fc rgb 0xeeffee behind
plot x**2
set obj 1 rect from screen 0.0,0.0 to screen 0.5,0.5 fc rgb 0xeeeeff behind
plot cos(x)
set obj 1 rect from screen 0.5,0.0 to screen 1.0,0.5 fc rgb 0xffffee behind
plot sin(x)/x
unset multiplot
### end of code
Result: