# Re: [R] How can I plot this graph

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Fri, 7 Dec 2007 01:07:22 -0500

Try this:

matplot(xxx[,1], xxx[2:4], type = "l")
with(xxx, {

```	segments(x, z1, x, z2)
points(x, z1)
points(x, z2)
```

})

Omit the two points commands if you don't want circles at the ends of the segments.

On Dec 6, 2007 6:30 PM, David Rees <davidrees1_at_yahoo.co.uk> wrote:
> Hi,
>
> I am having trouble plotting the graph I need given the follow kind of data
>
> > xxx <- data.frame(
> "x"=c(1,2,3,4,5),
> "y1"=c(2,4,3,5,6),
> "y2"=c(3,4,6,3,1),
> "y3"=c(1,3,5,7,3),
> "z1"=c(1,NA,3,5,NA),
> "z2"=c(2,NA,4,6,NA) )
> > xxx
> x y1 y2 y3 z1 z2
> 1 1 2 3 1 1 2
> 2 2 4 4 3 NA NA
> 3 3 3 6 5 3 4
> 4 4 5 3 7 5 6
> 5 5 6 1 3 NA NA
>
> What I need is the following
>
> - One graph
> - y1, y2, y3 plotted as seperate lines vs x
> - z1, z2 give the range of the value of z, and need to be plotted as error bars or confidence intervals vs x
>

> Many thanks for any help,
> Regards,
> David
>
>
> ---------------------------------
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help