[R] Adding a line to barchart
PIKAL Petr
petr.pikal at precheza.cz
Thu Jan 24 07:46:39 CET 2013
Hi
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Jonathan Greenberg
> Sent: Wednesday, January 23, 2013 5:44 PM
> To: r-help
> Subject: Re: [R] Adding a line to barchart
>
> Great! This really helped! One quick follow-up -- is there a trick to
> placing a label wherever the line intersects the x-axis (either above
> or below the plot)?
I am not sure if I understand what do you want. You probably could play with "if" part and add some code which places the label. Maybe you could read a wonderful article in last R journal about debugging grid graphics by Paul Murrell.
Regards
Petr
>
>
> On Tue, Jan 22, 2013 at 11:49 PM, PIKAL Petr <petr.pikal at precheza.cz>
> wrote:
>
> > Hi
> > This function adds line to each panel
> >
> > addLine <- function (a = NULL, b = NULL, v = NULL, h = NULL, ...,
> once
> > = F) {
> > tcL <- trellis.currentLayout()
> > k <- 0
> > for (i in 1:nrow(tcL)) for (j in 1:ncol(tcL)) if (tcL[i,
> > j] > 0) {
> > k <- k + 1
> > trellis.focus("panel", j, i, highlight = FALSE)
> > if (once)
> > panel.abline(a = a[k], b = b[k], v = v[k], h = h[k],
> > ...)
> > else panel.abline(a = a, b = b, v = v, h = h, ...)
> > trellis.unfocus()
> > }
> > }
> >
> >
> > addLine(v=2, col=2, lty=3)
> >
> > Petr
> >
> > > -----Original Message-----
> > > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> > > project.org] On Behalf Of Jonathan Greenberg
> > > Sent: Tuesday, January 22, 2013 11:42 PM
> > > To: r-help
> > > Subject: [R] Adding a line to barchart
> > >
> > > R-helpers:
> > >
> > > I need a quick help with the following graph (I'm a lattice
> newbie):
> > >
> > > require("lattice")
> > > npp=1:5
> > > names(npp)=c("A","B","C","D","E")
> > > barchart(npp,origin=0,box.width=1)
> > >
> > > # What I want to do, is add a single vertical line positioned at x
> =
> > > 2 that lays over the bars (say, using a dotted line). How do I go
> > > about doing this?
> > >
> > > --j
> > >
> > > --
> > > Jonathan A. Greenberg, PhD
> > > Assistant Professor
> > > Global Environmental Analysis and Remote Sensing (GEARS) Laboratory
> > > Department of Geography and Geographic Information Science
> > > University of Illinois at Urbana-Champaign
> > > 607 South Mathews Avenue, MC 150
> > > Urbana, IL 61801
> > > Phone: 217-300-1924
> > > http://www.geog.illinois.edu/~jgrn/
> > > AIM: jgrn307, MSN: jgrn307 at hotmail.com, Gchat: jgrn307, Skype:
> > > jgrn3007
> > >
> > > [[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.
> >
>
>
>
> --
> Jonathan A. Greenberg, PhD
> Assistant Professor
> Global Environmental Analysis and Remote Sensing (GEARS) Laboratory
> Department of Geography and Geographic Information Science University
> of Illinois at Urbana-Champaign
> 607 South Mathews Avenue, MC 150
> Urbana, IL 61801
> Phone: 217-300-1924
> http://www.geog.illinois.edu/~jgrn/
> AIM: jgrn307, MSN: jgrn307 at hotmail.com, Gchat: jgrn307, Skype: jgrn3007
>
> [[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.
More information about the R-help
mailing list