I am writing some plotting functions for a large time series database (extract of the data). I wrote a code to plot all the parameters (columns) against the time (first column of the data frame) linked to a given cycle (data frame). I am using a loop to plot all the parameters at once. The problem is that when I call the function, that uses the package ggplot2, only 20 plots out of the needed 34 appear in different windows. I obtain all plots between plot of parameter 11 (Gas_Flow_Mon_01) and plot of the last parameter 34 (Timer_24_Resettable_Value). I don't know if the problem lies within my code or if 20 is the full capacity of windows displayed at once using ggplot2? I have heard of functions like dev.off() but don't know if they would help in dealing with this issue.
# Function plotting all the parameters for one cycle using the indexes of the parameters and the cycle :
# `plot_cycle_allparameters_interactive()`
library(plotly)
library(tidyr)
plot_cycle_allparameters_interactive <- function(datafile,Cycle_index){
Cycle_name = names(datafile)[Cycle_index]
Cycle_data = datafile[[Cycle_name]]
# Cycle_data is the datafile studied that consists of multiple columns, each one representing a parameter
for(i in 2:length(Cycle_data)){
# looping through all the columns that represent a parameter
figure_interactive <- ggplot(Cycle_data, aes(x =Time,y = Cycle_data[,i], group= 1)) +
geom_line(color='blue')
print(ggplotly(figure_interactive))
dev.off()
}
}