I can't reduce the size of the legend in this plot. Could someone help me out? I want it to appear topright, but with no more than 20% of the height of plot area
a <- c(3, 2, 2, 2, 1, 2 ) barplot(a, beside = T, col = 1:6, space = c(0, 2)) legend("topright", legend = c("a", "b", "c", "d", "e", "f"), fill = 1:6, ncol = 2)
Steps. Create line1 and line2 using two lists with different line widths. To place a legend on the figure and to adjust the size of legend box, use borderpad=2 in legend() method. To display the figure, use show() method.
You can change the font size for a MATLAB legend by setting the 'FontSize' property of the Legend object. For example, plot four lines. Create a legend and assign the Legend object to the variable 'lgd'. Then, use dot notation to access the 'FontSize' property and set the value to 14 points.
In order to change the legend size in R you can make use of the cex argument. Values bigger than 1 will lead to a bigger legend and smaller to smaller legends than the default.
The cex
parameter will do that for you.
a <- c(3, 2, 2, 2, 1, 2 ) barplot(a, beside = T, col = 1:6, space = c(0, 2)) legend("topright", legend = c("a", "b", "c", "d", "e", "f"), fill = 1:6, ncol = 2, cex = 0.75)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With