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)
Try autoplot.zoo
. (continued below plot)
library(ggplot2)
library(zoo)
autoplot(zoo(data), facet = NULL) + geom_point()
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()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With