Yes, if you check help key
, there seems to be no option to set the background color of the key box.
A workaround might be the following:
With opaque
, the key box will be filled with the background color.
So, the "trick" is to the change the background color of the terminal to the desired key box color, but then add, e.g. a white rectangle spanning the whole screen. Do not forget to use the option behind
. Additionally, to avoid a residual line at the border of the screen, set the coordinates of the rectangle from -0.1,-0.1
to 1.1,1.1
.
It works with wxt terminal. You need to test whether this works also with other terminals.
Code:
### key background
reset session
set term wxt background rgb "grey"
set object 1 rectangle from screen -0.1,-0.1 to screen 1.1,1.1 fc rgb "white" behind
set key opaque font ",12"
plot sin(x), cos(x)
### end of code
Result:

Addition:
@johnymm, for me it also works fine with pdfcairo terminal.
### key background
reset session
set term pdfcairo background rgb "grey"
set output "KeyBackground.pdf"
set style rect fc rgb "white" fs noborder
set object 1 rectangle from screen 0,0 to screen 1,1 behind
set key opaque font ",12"
plot sin(x), cos(x)
set output
### end of code