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)
You can also do it without external packages if you wish:
You can create a similar plot in ggplot, but you will need to do some reshaping of the data first.
My output:
Try
autoplot.zoo
. (continued below plot)giving:
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()
.