Initial script for bar plotting. Continued line plot script (started in the last commit, but forgot to mention it).

This commit is contained in:
antux18 2024-08-07 20:50:42 +02:00
parent e2903ffac1
commit 5aae58d680
2 changed files with 23 additions and 4 deletions

17
plot/bar_plot.r Executable file
View File

@ -0,0 +1,17 @@
#!/usr/bin/env Rscript
# Parsing command line arguments:
options = commandArgs(trailingOnly = TRUE)
filename = options[1]
table_header = options[-1]
# Loading files:
table = read.csv(filename, header = FALSE, row.names = length(table_header) + 1) # The last column of the table gives the timestamp, thus the row names
# Setting up the table so it can be plotted:
colnames(table) = table_header
# Transposing for bar plotting:
table = t(as.matrix(table))
# Plotting:
barplot(table)

View File

@ -5,13 +5,15 @@ library(ggplot2)
library(reshape2)
# Parsing command line arguments:
options <- commandArgs(trailingOnly = TRUE)
options = commandArgs(trailingOnly = TRUE)
filename = options[1]
table_header = options[-1]
# Loading files:
table = read.csv(options[1], header = FALSE)
colnames(table) = c("dpkg", "pip", "git", "misc", "timestamp")
table = read.csv(filename, header = FALSE)
# Setting up the table so it can be plotted:
colnames(table) = table_header
melted_table = melt(table, id.vars = "timestamp", variable.name = "category")
# Plotting: