Jason Rupert
2009-Jan-29 19:03 UTC
[R] Adding vertical line to histogram and qplot "stacked" plot
R-users it appears I am leaning on your knowledge once again. Is there any way to add a vertical line to a histogram and qplot "stacked" plot? Here is my current attempt: "qplot" approach attempt: qplot(Run, data = data_dataframe, breaks = breaks, fill = Temperature, main = short_title) + scale_x_continuous("Data") + scale_y_continuous("Freq") + scale_fill_discrete("Temperature") + scale_fill_manual(values = c(LOW = "blue", AMB ="black", HIGH = "red")) + geom_abline(v = HighVal, col = "dodgerblue3", lty="dotdash") "hist" approach attempt: hist(data_dataframe, breaks = breaks, col = "dodgerblue3", xlab="Data", freq = TRUE, main="") +abline(v = HighVal, col = "dodgerblue3", lty="dotdash") Neither seem to be working. I think I am missing something small to get this to work. Thank you again for any feedback you can provide. [[alternative HTML version deleted]]
Felipe Carrillo
2009-Jan-29 19:14 UTC
[R] Adding vertical line to histogram and qplot "stacked" plot
Jason: Check Hadley's page, there's a few examples there. Good luck http://had.co.nz/ggplot2/geom_vline.html Felipe D. Carrillo Supervisory Fishery Biologist Department of the Interior US Fish & Wildlife Service California, USA --- On Thu, 1/29/09, Jason Rupert <jasonkrupert at yahoo.com> wrote:> From: Jason Rupert <jasonkrupert at yahoo.com> > Subject: [R] Adding vertical line to histogram and qplot "stacked" plot > To: R-help at r-project.org > Date: Thursday, January 29, 2009, 11:03 AM > R-users it appears I am leaning on your knowledge once > again.? Is there any way to add a?vertical line to a > histogram and qplot "stacked" plot?? Here is my > current attempt: > ? > "qplot" approach attempt: > qplot(Run, data = data_dataframe, breaks = breaks, fill > Temperature,?main = short_title) > +?scale_x_continuous("Data") + > scale_y_continuous("Freq") > +??scale_fill_discrete("Temperature") + > scale_fill_manual(values = c(LOW = "blue", AMB > ="black", HIGH = "red")) +? > geom_abline(v = HighVal, col = "dodgerblue3", > lty="dotdash") > ? > ? > "hist"?approach attempt: > hist(data_dataframe, breaks = breaks,? col > "dodgerblue3", xlab="Data", freq = TRUE, > main="") +abline(v = HighVal, col > "dodgerblue3", lty="dotdash")?? > ? > Neither seem to be working.? I think I am missing > something small to get this to work.? > ? > Thank you again for any feedback you can provide. > > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, > reproducible code.
Duncan Murdoch
2009-Jan-29 19:26 UTC
[R] Adding vertical line to histogram and qplot "stacked" plot
On 1/29/2009 2:03 PM, Jason Rupert wrote:> R-users it appears I am leaning on your knowledge once again. Is there any way to add a vertical line to a histogram and qplot "stacked" plot? Here is my current attempt: > > "qplot" approach attempt: > qplot(Run, data = data_dataframe, breaks = breaks, fill = Temperature, main = short_title) + scale_x_continuous("Data") + scale_y_continuous("Freq") + scale_fill_discrete("Temperature") + scale_fill_manual(values = c(LOW = "blue", AMB ="black", HIGH = "red")) + geom_abline(v = HighVal, col = "dodgerblue3", lty="dotdash") > > > "hist" approach attempt: > hist(data_dataframe, breaks = breaks, col = "dodgerblue3", xlab="Data", freq = TRUE, main="") +abline(v = HighVal, col = "dodgerblue3", lty="dotdash") >Are you using ggplot2? It uses that notation of adding elements to a plot. Classic graphics doesn't, so you would just give the different commands separately on each line, e.g. hist(data_dataframe, breaks = breaks, col = "dodgerblue3", xlab="Data", freq = TRUE, main="") abline(v = HighVal, col = "dodgerblue3", lty="dotdash")