round rectangle borders and backgrounds
Usage
element_roundrect(
fill = NULL,
colour = NULL,
linewidth = NULL,
linetype = NULL,
color = NULL,
r = grid::unit(0.1, "snpc"),
inherit.blank = FALSE
)Arguments
- fill
Fill colour.
fill_alpha()can be used to set the transparency of the fill.- colour, color
Line/border colour. Color is an alias for colour.
alpha()can be used to set the transparency of the colour.- linewidth
Line/border size in mm
- linetype
Line type for lines and borders respectively. An integer (0:8), a name (blank, solid, dashed, dotted, dotdash, longdash, twodash), or a string with an even number (up to eight) of hexadecimal digits which give the lengths in consecutive positions in the string.
- r
the radius of the rounded corners, a
unitobject, default is unit(0.1, 'snpc').- inherit.blank
Should this element inherit the existence of an
element_blankamong its parents? IfTRUEthe existence of a blank element among its parents will cause this element to be blank as well. IfFALSEany blank parent element will be ignored when calculating final element state.
Examples
library(ggplot2)
p <- ggplot(mpg, aes(displ, cty)) + geom_point()
p <- p + facet_grid(cols = vars(cyl))
p <- p + theme(strip.background=element_roundrect(fill="grey40", color=NA, r=0.15))
p
p2 <- ggplot(mtcars, aes(mpg, disp, color=factor(cyl), size=cyl)) +
geom_point()
p2 + theme(legend.background=element_roundrect(color="#808080", linetype=2))