[英]ggplot legend at top but below title?
Is there a way to make ggplot place the legend on top but below the title? 有没有办法让ggplot将传奇放在顶部但在标题下面?
As an example... 举个例子...
..produced with the following code: ..使用以下代码生成:
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="")
Any suggestions would be greatly appreciated? 任何建议将不胜感激?
Edit Ignore this. 编辑忽略此项。 The issue is not longer a problem.
问题不再是问题。 But the code has been updated so that it no longer throws an error.
但代码已更新,以便它不再抛出错误。
While waiting for the next version, you can fine tune within ggplot2. 在等待下一个版本时,您可以在ggplot2中进行微调。 For instance:
例如:
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 = "")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.