- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to change the background color of legend in base R plot?
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".
Example1
plot(1:10) legend("right",legend="point chart",bg="blue")
Output
Example2
plot(1:10) legend("right",legend="point chart",bg="light green")
Output
Example3
plot(1:10) legend("left",legend="point chart",bg="light grey")
Output
- Related Articles
- How to change the background color of base R plot region?
- How to change the font size of legend in base R plot?
- How to change the axis color in base R plot?
- How to change the axis ticks color in base R plot?
- How to change the background color of a plot created by using plot function in R?
- How to change the border color of box of a base R plot?
- How to change the color of bars in base R barplot?
- How to change the resolution of a plot in base R?
- How to change the color of box of boxplot in base R?
- Change the color of legend element border using ggplot2 in R.
- How to change the partial plot background using ggplot2 in R?
- How to change the color of outliers in base R boxplot?\n
- How to change the position of X-axis in base R plot?
- How to change the Y-axis title in base R plot?
- How to change the plot border color of a ggplot2 graph in R?

Advertisements