n <- 25
s <- seq(0, 1, length.out = n+1)[-(n+1)]
df <- data.frame( "t" = s, "x" = cos(2*pi*s), "y" = sin(2*pi*s) )
ggplot(df) +
  geom_stream(aes(x, y, t = t)) +
  coord_equal()
ggplot(df) +
  geom_stream(aes(x, y, t = t, alpha = t), size = 5) +
  coord_equal()
ggplot(df) +
  geom_path(aes(x, y, alpha = t), size = 5) +
  coord_equal()
stream_1 <- data.frame(
  x = c(0, 3),
  y = c(0, 0),
  t = 0:1
)
stream_2 <- data.frame(
  x = c(1, 1),
  y = c(1, 5),
  t = 0:1
)
stream_3 <- data.frame(
  x = c(2, 5),
  y = c(2, 6),
  t = 0:1
)
streams <- rbind(
  cbind(stream_1, id = 1),
  cbind(stream_2, id = 2),
  cbind(stream_3, id = 3)
)
ggplot(stream_1) +
  geom_stream(aes(x = x, y = y, t = t))
# set group aes if multiple vectors
ggplot(streams) +
  geom_stream(aes(x = x, y = y, t = t, group = id))
Run the code above in your browser using DataLab