[Solved] plot multiple lines in ggplot


I’ll make some fake data (I won’t try to transcribe yours) first:

set.seed(2)
x <- data.frame(
  Date = rep(Sys.Date() + 0:1, each = 24),
  # Year, Month, Day ... are not used here
  Hour = rep(0:23, times = 2),
  Value = sample(1e2, size = 48, replace = TRUE)
)

This is a straight-forward ggplot2 plot:

library(ggplot2)
ggplot(x) +
  geom_line(aes(Hour, Value, color = as.factor(Date))) +
  scale_color_discrete(name = "Date")

sample ggplot

ggplot(x) +
  geom_line(aes(Hour, Value)) +
  facet_grid(Date ~ .)

sample ggplot, faceted

I highly recommend you find good tutorials for ggplot2, such as http://www.cookbook-r.com/Graphs/. Others exist, many quite good.

1

solved plot multiple lines in ggplot