library(ggplot2)
p <- ggplot(iris,aes(Sepal.Width,Petal.Length))+
geom_line()
p
Imagine that you have a ggplot object and you have no access to the code or data that created this plot. How does one adjust the size/thickness of the plotted line?
I have tried modifying the theme, but that only changes the background lines and not the plotted lines.
p+
theme(line=element_line(size=10))
For more complex ggplots, where you don't know which layers are the geom_line
layers, you will have to pick out which layers are geom_line
layers to rewrite their aesthetic parameters:
geomlines <- which(sapply(p$layers, function(x) class(x$geom)[1] == "GeomLine"))
p$layers[geomlines] <- lapply(p$layers[geomlines], function(x) {
x$aes_params$size <- 2
x
})
p
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.