Suppose I have a dataset of carrot yield from different fields and different breeds:
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)
I want to build a graph showing the yield for each field colored by rocks:
ggplot(carrots,aes(y=Yield,x=Field,fill=Breed)) +
geom_bar() +
opts(legend.direction = "horizontal",
legend.position = "top") +
labs(fill="")
But the legend always slightly overlaps the plot area:
plot with a little overlap of legends http://users.utu.fi/susjoh/Rplot.png
I tried to manually adjust the position of the legend, being out of the chart area, for example
opts(legend.position=c(0.5,1.1)
but then the graph fields cut off the legend, and I'm not sure how I can customize them. Is there a finer solution to this problem?