Home > Enterprise >  Time Series Graphs with Different Symbols
Time Series Graphs with Different Symbols

Time:03-05

I randomly simulated this time series data:

n_obs = 1:100

a1 = rexp(100,5)
b1 = rexp(100,5)

a1_col = "red"
b1_col = "blue"

symbol <- c("square","triangle")

point_symbol <- sample(symbol, 100, replace=TRUE, prob=c(0.5, 0.5))

stock_data = data.frame(n_obs, a1, b1, a1_col, b1_col, point_symbol)

stock_data$point_symbol_color = ifelse(stock_data$a1 > stock_data$b1, "hollow", "dark")

I was able to make a graph of this data:

library(ggplot2)

ggplot()   
  geom_line(data = stock_data, aes(x = n_obs, y = a1), color = "red")  
  geom_line(data = stock_data, aes(x = n_obs, y = b1), color = "blue")  
  xlab('n_obs')  
  ylab('exp value')   ggtitle("sample")

enter image description here

  • Is it possible to change the "shape" of each point according to the symbols I indicated above? I think this can be done with the following commands (enter image description here

  • Related