Skip to content

Commit

Permalink
changed code for plot for problems with library
Browse files Browse the repository at this point in the history
  • Loading branch information
josura committed Jul 13, 2023
1 parent aebc10f commit 411a1b6
Showing 1 changed file with 27 additions and 5 deletions.
32 changes: 27 additions & 5 deletions scripts/R/plotTimeSeriesToyExample.R
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
library(ggplot2)

timeSeries.t0 <- read.csv("/home/josura/Projects/ccc/c2c-sepia/outputsTimeSeries/t2_outputAll.tsv",sep = "\t",header = TRUE)
timeSeries.t2 <- read.csv("/home/josura/Projects/ccc/c2c-sepia/outputsTimeSeries/t2_outputAll.tsv",sep = "\t",header = TRUE)

library(tidyverse)
library(dplyr)


x <- timeSeries.t0[, 1]
y <- timeSeries.t0[, (ncol(timeSeries.t0)-11):ncol(timeSeries.t0)]
x <- timeSeries.t2[, 1]
y <- timeSeries.t2[, (ncol(timeSeries.t2)-11):ncol(timeSeries.t2)]

# Select only the interesting columns
#interesting.list <- c("v.in.t3","v.in.t1","v.in.t2","v.out.t3","v.out.t1","v.out.t2")
interesting.list <- c("v.in.t3","v.in.t1","v.out.t3","v.out.t1","v.out.t2")
y.int <- timeSeries.t0[, interesting.list]
y.int <- timeSeries.t2[, interesting.list]

# Combine x and y into a new dataframe
df_new <- data.frame(x = rep(x, ncol(y)), y)
Expand All @@ -27,3 +27,25 @@ ggplot(df_new, aes(x = x, y = value, color = variable)) +
scale_color_discrete(name = "Y Variables") +
facet_wrap(~ variable, ncol = 3) # Adjust the number of columns as needed


# Combine x and y into a new dataframe
df_new <- data.frame(x = rep(x, ncol(y)))
df_new <- cbind(df_new, y)

# Reshape the data by converting columns into a single column
df_new <- data.frame(
x = rep(df_new$x, times = ncol(y)),
variable = rep(colnames(y), each = nrow(y)),
value = c(t(y))
)


# Plot the matrix of scatter plots
ggplot(df_new, aes(x = x, y = value, color = variable)) +
geom_point() +
labs(x = "X Axis", y = "Y Axis") +
scale_color_discrete(name = "Y Variables") +
facet_wrap(~ variable, ncol = 3) # Adjust the number of columns as needed


plot(df_new[df_new$variable == "a",]$x,df_new[df_new$variable == "a",]$value)

0 comments on commit 411a1b6

Please sign in to comment.