In the code below, is it possible to make the legend background semi-transparent? I cannot pass analpha
value toelement_rect()
inlegend.background
orlegend.box.background
to do this. As an example,tm_layout()
intmap
package can do this with argumentslegend.bg.color = "white"
andlegend.bg.alpha = 0.5
.
suppressMessages(library(ggmap))
data(crime)
houston.map <- get_map(location = geocode("Houston"),
zoom = 14,
maptype = "satellite")
ggmap(houston.map, extent = "device", legend = "topleft") +
geom_point(aes(x = lon, y = lat, color = offense), data = crime) +
theme(legend.background = element_rect(fill = alpha("white", 0.7)),
legend.key = element_rect(color = NA, fill = NA))
Update: Thanks to jazzurro I updated the code to passalpha()
inelement_rect(),
and the attached picture is how it looks. This answers my question.