I am running into problems with these 2 requirements:
- y-axis must start at 3
- some
geom_textwill range out of chart on the right

My ideas so far and their flaws:
- subtract -3 from all datasets and fake y-axis labels (would prefer not to)
- build a dummy
geom_barof height 3 (how to keep it out of legend?)
Any ideas would be appreciated!
library(grid)
library(ggplot2)
df=data.frame(
Date=c("2012-11-30", "2012-12-03", "2012-12-04"),
d1=c(12, 8, 13),
d2=c(13, 7, 12),
e1=c(7, 9, 8)
)
frame()
p=ggplot(df, aes(Date)) +
geom_bar(aes(y=e1, fill="e1"), stat="identity", color="red") +
geom_line(aes(y=d1, group=1, color="d1")) +
geom_line(aes(y=d2, group=1, color="d2")) +
geom_text(aes(x =3.5, y=c(14,13,12), label=c("Text1","Text2","Text3"))) +
scale_colour_manual(" ", values=c("e1"="red", "d1"="blue", "d2"="black"))+
scale_fill_manual("", values="red") +
coord_cartesian(ylim=c(3,15), xlim=c(0.5,3.5)) +
theme(legend.key=element_blank(),legend.title=element_blank(),
legend.position="top", legend.box="horizontal",
plot.margin=unit(c(1, 2, 1, 1), "cm"))
p1 <- ggplot_gtable(ggplot_build(p))
p1$layout$clip[p1$layout$name=="panel"] <- "off"
grid.draw(p1)
you define your own scale transformation
then you add
I don’t understand where do you want to put the geom_text exactly.
PS : Sorry , I change the alpha to 0.5 because your red hurts my eyes.