Change Legend Size in Base R Plot
In this article, we will be looking at the approach to change the size of the legend in the plot in the R programming language.
To change the legend size of the plot, the user needs to use the cex argument of the legend function and specify its value with the user requirement, the values of cex greater than 1 will increase the legend size in the plot and the value of cex less than 1 will decrease the size of the legend in the plot.
Syntax: legend(x, y, legend, fill, col, bg, lty, cex, title, text.font, bg)
- x and y: These are co-ordinates to be used to position the legend
- legend: Text of the legend
- fill: Colors to use for filling the boxes with legend text
- col: Colors of lines
- bg: It defines background color for the legend box
- cex: Used for scaling
- title: Legend title (optional)
- text.font: An integer specifying the font style of the legend (optional)
Returns: Legend plot
cex is a number indicating the amount by which plotting text and symbols should be scaled relative to the default. 1=default, 1.5 is 50% larger, 0.5 is 50% smaller, etc.