'GGplot2 in combination with Guide_legend arguments
theme_pubr in the ggpubr package by default creates legends with the title on the side and the variables distributed horizontally. However,i'm trying to make a legend with the title on top and the species in one column.
I have tried using guides(colour=guide_legend(ncol=1)) and
guides(colour = guide_legend(title.position = "top")) in combination, however one seems to override the other. Can anybody explain why this happens and how to work around it?
example code using the iris dataset.
library(ggplot2)
library(datasets)
library(ggpubr)
ggplot(iris,aes(Species, Petal.Length))+
geom_point(aes(colour= Species))+
theme_pubr()+
labs_pubr()+
guides(colour=guide_legend(ncol=1))+
guides(colour = guide_legend(title.position = "top"))
Thanks in advance,
Stuart
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
