Is there free software to graph (draw) a time series plot over a period of time that I specify?

86 Views Asked by At

I have some data measured at 15 minute intervals. For a presentation, I'd like to plot (animate?) the data over the course of 30 seconds or so, so that the audience can have a sense of the changes at certain times of the day. My data is in space delimited text format.

Thanks!

1

There are 1 best solutions below

1
On

You can try the following approach in R to get a plot similar to that shown below. enter image description here

# Set the working directory
setwd(".")

# Load required packages
require("ggplot2")
require("animation")

#----------------------------------------------
# Curve animation function
#----------------------------------------------
animatePlot <- function(timeList, valueList) {
  lapply(seq(0, length(timeList), 1), function(time_index) {
    plotCurve(timeList[1:time_index], valueList[1:time_index])
  })
}

#----------------------------------------------
# Function to actually plot each snapshot
#----------------------------------------------
plotCurve <- function(timeList, valueList) {
  df = data.frame(Time = timeList, Value = valueList)
  plt = ggplot(data = df) +
        geom_line(aes(x = Time, y = Value), color = "blue", size = 1) +
        xlab("Time (min.)") +
        ylab("Value ") +
        coord_cartesian(xlim = c(0, 1000), ylim = c(-3,3)) +
        theme_bw()
  print(plt)
}

#==============================================
# Load the time series file
# df = read.csv("timeseries.dat", sep="")

# Create data frame for testing
times = seq(from = 0, to = 1000, by = 15)
set.seed(1000)
values = rnorm(length(times))

# Create animation
saveGIF(animatePlot(times, values), interval = 0.2, movie.name = "animation.gif")