[R] ggplot specify line type

Brian Diggs diggsb at ohsu.edu
Fri Oct 19 23:36:43 CEST 2012


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




More information about the R-help mailing list