sm_common_legend {smplot2} | R Documentation |
Creating a common legend for subplots on a separate panel
Description
Creating a common legend for subplots on a separate panel
Usage
sm_common_legend(
x = 0.5,
y = 0.5,
title = FALSE,
direction = "vertical",
border = TRUE,
legend_spacing = 0.5,
border_color = "black",
textRatio = 1
)
Arguments
x |
Location of the legend along the x-axis. Default is the middle origin (0.5). |
y |
Location of the legend along the y-axis. Default is the middle origin (0.5). |
title |
Title of the legend. Input should be string |
direction |
Direction of the legend: 'horizontal' or 'vertical'. |
border |
If set TRUE, border around the legend will be created. If set FALSE, the border will be removed. |
legend_spacing |
Spacing within the legend. |
border_color |
Color of the legend border |
textRatio |
Size of the text relative to the plot's default. It has been set to 1.2. The larger the textRatio, the larger the texts in the legend. |
Value
It prints a legend on a blank plot. It can be used to create a common legend for subplots.
Examples
library(ggplot2)
library(smplot2)
ggplot(data = mtcars, mapping = aes(x = drat, y = mpg,
fill = as.factor(cyl))) +
geom_point(shape = 21, color = 'white', size = 3) +
sm_common_legend(x = .5, y = 0.5 , direction='horizontal',
border=FALSE)
[Package smplot2 version 0.2.4 Index]