有没有办法让ggplot将传奇放在顶部但在标题下面?
举个例子...
..使用以下代码生成:
carrots<-list(Yield=c(345,226,74,559,288,194),
Field=c("A","B","C","D","E","F"),
Breed=rep(c("Long","Short"),each=3))
carrots<-data.frame(carrots)
ggplot(carrots,aes(y=Yield,x=Field,fill=Breed)) +
geom_bar() +
opts(title="Title",
legend.direction = "horizontal",
legend.position = "top") +
labs(fill="")
Run Code Online (Sandbox Code Playgroud)
任何建议将不胜感激?
编辑 忽略这一点。这个问题不再是问题了。但代码已更新,不再抛出错误。
在等待下一个版本的同时,您可以在 ggplot2 内进行微调。例如:
ggplot(carrots, aes(y = Yield, x = Field, fill = Breed)) +
geom_bar(stat = "identity") +
theme(
plot.margin = unit(c(2, 1, 1, 1), "cm"),
plot.title = element_text(size = 30, face = "bold", colour = "blue", vjust = 7),
legend.direction = "horizontal",
legend.position = c(0.1, 1.05)) +
ggtitle("Title") +
labs(fill = "")
Run Code Online (Sandbox Code Playgroud)