data visualization - Graphing Scatter Plots in R -
i'm trying graph simulated model of infectious disease spread.
my data has 3 columns, x, y, , infection time. need plot each point (x coordinate, y coordinate) @ each time (t), t runs between 1 , 4. i'm looking 4 graphs, 1 @ each time, first graphs plots first infected point, second plots infected points @ time 1 , 2, etc.
i know can multiple graphs using par(mfrow=c(2,2)), i'm not sure how incorporate each time code. suggestions?
there thousand ways this, depending on original data set. learning ggplot2 best in long run. using base graphics, though, can make plot each subset of data (and can use subset command instead of t<=ti, customize colors, etc):
par(mfrow=c(2,2)) (ti in 1:4){ plot(x[t <= ti], y[t <= ti]) } if trying convey passage of time, might want plot entire range of data invisibly on each plot, set same axes. use points or lines plot data each of identical frames...
par(mfrow=c(4,1)) (ti in 1:4){ plot(x, y, type="n") points(x[t <= ti], y[t <= ti]) }
Comments
Post a Comment