How to plot two charts with same X axis in R? -
how plot 2 charts using same x axis in r ggplot2?
i looking like: http://i.stack.imgur.com/b9qt7.png
the basic idea melt data set have values of variables want plot on y axis in single column, second column distinguishing source. example:
data("economics") dat.m <- melt(economics, measure.vars=c("pop", "unemploy"))
then use facet_grid plot each variable in separate facet:
ggplot(dat.m, aes(x=date, y=value)) + geom_line() + facet_grid(variable~., scales="free_y")
Comments
Post a Comment