简体   繁体   中英

Multiple lines on a graph for R

I have this data:

 >x<-seq(0,30,by=1) 
 >y<-dbinom(x,30,0.3)
 >plot(x,y)
 >plot(x,y,type="h",lty=1)
 >plot(x,y,type="l",lty=3)

and I'm not too sure how to plot it all on one graph. The three different plot() functions are the same line, just one is dotted, one has circles for points and the other has lines up to the points, I just need to combine them. Thanks

You can use the functions ?lines and ?points to achieve this:

plot(x,y,type="h",lty=1)
points(x,y)
lines(x,y,lty=3)

第一个图应该是plot()和其他所有 - lines()或points()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM