[R] Lattice: arbitrary abline in multiple histograms
David Winsemius
dwinsemius at comcast.net
Wed Oct 13 03:13:30 CEST 2010
On Oct 12, 2010, at 8:21 PM, Alejo C.S. wrote:
> Dear list.
>
> I have three histograms and I want to add a vertical abline in a
> different
> place in each plot. The next example will plot a vertical line at
> x=5.5 in
> the three plots:
>
> rnorm(100,5,3) -> A
> rnorm(100,7,3) -> B
> rnorm(100,4,1) -> C
> rep(c("A","B","C"),each=100) -> grp
> data.frame(G=grp,D=c(A,B,C)) -> data
> histogram(~ D | G, data=data, layout=c(3,1), nint=50,
> panel=function(x,...){
> panel.histogram(x,...)
> panel.abline(v=5.5)
> })
> But I'd like to plot a vertical line at 5.5 in plot A, 6.5 in plot B
> and
> 4.5 in plot C. How can I do that?
histogram(~ D | G, data=data, layout=c(3,1), nint=50,
panel=function(x,subscripts,groups,...){
panel.histogram(x,...)
panel.abline(v=c(5.5, 6.5, 4.5)[packet.number()])
})
>
> Thanks in advance..
>
> A.
>
> [[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.
David Winsemius, MD
West Hartford, CT
More information about the R-help
mailing list