To create the legend for a plot in base R, we can use legend function and if the background color of the legends needs to be changed from white to any other then bg argument in legend function will be used. For example, to change the background color to red then we can use bg="red".
plot(1:10) legend("right",legend="point chart",bg="blue")
plot(1:10) legend("right",legend="point chart",bg="light green")
plot(1:10) legend("left",legend="point chart",bg="light grey")