Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ggplot equivalent for matplot

Tags:

r

ggplot2

Is there an equivalent in ggplot2 to plot this dataset? I use matplot, and read that qplot could be used, but it really does not work. ggplot/matplot

data<-rbind(c(6,16,25), c(1,4,7), c(NA, 1,2), c(NA, NA, 1))
as.data.frame(data)
matplot(data, log="y",type='b', pch=1)

plot columns / each line

like image 538
catindri Avatar asked Jun 22 '15 10:06

catindri


1 Answers

Try autoplot.zoo. (continued below plot)

library(ggplot2)
library(zoo)

autoplot(zoo(data), facet = NULL) + geom_point()

giving:

screenshot

Note that if data had column names then the legend would have used them. Also if different line types were wanted then append + aes(linetype = Series). If log10 y axis were desired then append + scale_y_log10() .

like image 114
G. Grothendieck Avatar answered Sep 18 '22 13:09

G. Grothendieck