Skip to content
Back to formatted view

Raw Message

Message-ID: <5081C7EB.8050608@ohsu.edu>
Date: 2012-10-19T21:36:43Z
From: Brian Diggs
Subject: ggplot specify line type
In-Reply-To: <1350672172609-4646789.post@n4.nabble.com>

On 10/19/2012 11:42 AM, autumnlin wrote:
> <http://r.789695.n4.nabble.com/file/n4646789/1.bmp>
>
> hi is it possible to draw a graph like the attached one using ggplot?

Yes

> how should i code it in r?

Use a geom_point() where the shape aesthetic is mapped to the grouping 
variable and also add a geom_line(). If your horizontal axis is 
discrete, then you will need to set the grouping in the geom_line() 
correctly.

This answer is vague because the question was. Reproducible data and 
examples are appreciated/expected.  Here is code for a similar sort of 
graph.

ggplot(mtcars, aes(x=mpg, y=wt, shape=factor(carb))) +
     geom_point() +
     geom_line()

> thanks.
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/ggplot-specify-line-type-tp4646789.html
> Sent from the R help mailing list archive at Nabble.com.
>


-- 
Brian S. Diggs, PhD
Senior Research Associate, Department of Surgery
Oregon Health & Science University