Commit 04e54065 authored by Toni's avatar Toni
Browse files

Improved R plotting

Plotting orders legend by line order in graph
parent 626c153e
$title Run Rscript do_r_plot.r
Set
t "Time (e.g. hours) " /t1*t200/
c "Structure measurement point (Celcius) " /outside, wall, inside/
c "Structure measurement point (Celcius) " / inside, wall, outside/
;
Parameter
p(t,c) "Building temperature (celcius) "
......
......@@ -22,6 +22,7 @@ library(ggplot2)
library(optparse)
library(tools)
library(rlang)
library(forcats)
#Preprocessing : delete old pdf
pdf_name="Rplots.pdf"
......@@ -125,10 +126,10 @@ yvar <- sym(colnames(df_p)[2])
value <- sym(colnames(df_p)[3])
xlabel <- paste(xvar_desc,xvar,"(",xvar_labels[1,1],"=1, ...,",xvar_labels[window_end,1],"=",window_end,")")
ylabel <- paste(yvar_desc,yvar)
g <- ggplot(df_p, aes(x=!!xvar, y=!!value, group=!!yvar, color=!!yvar)) + geom_line() + ggtitle(ptitle) + xlab(xlabel) + ylab(ylabel)
g <- ggplot(df_p, aes(x=!!xvar, y=!!value, group=!!yvar, color=fct_reorder2(df_p[,2],df_p[,1],df_p[,3]))) + labs(colour = yvar) + geom_line() + theme(text = element_text(size=6))+ scale_color_brewer(palette = "Dark2") + ggtitle(ptitle) + xlab(xlabel) + ylab(ylabel) + theme(legend.position="bottom", legend.text = element_text(size=6))
# create PDF
pdf(file = pdf_name, width = 6.25, height = 4, family = "Times", pointsize = 8, onefile = TRUE)
pdf(file = pdf_name, width = 6.25, height = 4, family = "Times", pointsize = 6, onefile = TRUE)
print(g)
cnt_plots=1;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment