As you're using it, geom_hline(yintercept = dline, ...) expects dline
to be a constant since it is not within an aes() statement. Inside
aes(), dline would be expected to be a vector. If dline is neither of
these, you may have to rethink your code.
HTH,
Dennis
> --
> You received this message because you are subscribed to the ggplot2 mailing list.
> Please provide a reproducible example: http://gist.github.com/270442
>
> To post: email ggp...@googlegroups.com
> To unsubscribe: email ggplot2+u...@googlegroups.com
> More options: http://groups.google.com/group/ggplot2
>
Thank you for giving me the hints.
1) I have created an object for geom_hline (for 3 facets) successfully as follows: anyline <- subset (overall, flag_var=='any', select=c(percent, age)).
Per your hint, I have included anyline within the aes (). I it gives me 3 horizontal lines for each of the 3 facets. But I want only 1 horizontal line for each facet.
Any advice or hint to resolve the issue?
p <- ggplot(dd, aes(y=percent, x=race, fill=race ))+
geom_bar(position=dodge) +
geom_errorbar(ddlimits, position=dodge, width=0.3) +
facet_wrap(~ age, ncol=numcol)+
geom_hline(aes(yintercept=anyline$percent, colour="red", linetype=2))+
scale_fill_manual(values=colours)+
xlab("")+
ylab("Percentage")+
coord_flip ()+
2) When using the anyline via an argument (dline), it says dline is not found.
plotfun <- function(dd, ddlimits, dline, numcol, plotTitle, outFile)
plotfun(danydis, lanydis, anyline, canydis, tanydis, 'abodill_race.png')
___________________________
Regards,
Pradip Muhuri
_____________
From: Dennis Murphy [djm...@gmail.com]
Sent: Friday, October 07, 2011 6:01 PM
To: Muhuri, Pradip (SAMHSA/CBHSQ)
Cc: ggplot2
Subject: Re: Adding a horizontal line to geom_bar facet graph
geom_hline(data = anyline, aes(yintercept=percent), colour="red", linetype=2) +
...
in the middle of the code chunk that generates p.
This is similar to a post from earlier this week:
http://groups.google.com/group/ggplot2/browse_thread/thread/cffc07233c124b33
HTH,
Dennis
I have tried what you had suggested. That did not work. Any other suggestions?
Thank you for continued support.
Pradip Muhuri
________________________________________
From: Dennis Murphy [djm...@gmail.com]
Sent: Saturday, October 08, 2011 12:10 PM