Skip to content

Commit

Permalink
Pore water plots: option for different facets added
Browse files Browse the repository at this point in the history
  • Loading branch information
joboog committed Jan 26, 2018
1 parent bbac685 commit 22a42e0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Code/Support.R
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,13 @@ summary_table3 <- function(df,col_n, ByFactor, ByFactorCol){

# ==== Pore water plots ===============================================================

myGGPoreWQPlot <- function(df, plottitle){
myGGPoreWQPlot <- function(df, facet_var, plottitle){
plot <- ggplot(data = na.omit(df), aes(x=dist_axial, y=mean, color=System)) +
geom_errorbar(aes(ymin=mean-sd, ymax=mean+sd), width=.1) +
geom_line() +geom_point()
if (length(unique(df$Parameter))>1)
{
plot <- plot + facet_grid(Parameter~System, scales = "free_y") + labs(title=plottitle)
plot <- plot + facet_grid(facet_var, scales = "free_y") + labs(title=plottitle)
}
return(plot)
#geom_smooth(aes(fg=System, group=Parameter), method="loess", span=1 , se=FALSE)
Expand Down
17 changes: 10 additions & 7 deletions server.R
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ function(input, output){
#== plot type ? ==

if (input$WQ_plotypeInput=="Time series"){

#plot
wq_plot <- ggplot(data = na.omit(df2_WQ()), aes(x=DateTime, y=value, color=SamplePoint)) +
geom_line()+geom_point() + facet_grid(facet_var, scales = "free_y") + theme_bw() + labs(x="")

#plot
#wq_plot

}


Expand All @@ -112,27 +112,30 @@ function(input, output){
Parameter %in% input$WQ_parameterInput,
System=="SEP"
)
# get system names
systems <- unique(df2_WQ()$System)

systems <- unique(df2_WQ()$System)
df2_WQ_temp2 <- df2_WQ()
df2_WQ_temp2 <- df2_WQ()

for (i in 1:length(systems)){
df2_WQ_temp2 <- bind_rows(df2_WQ_temp2, df2_WQ_temp1)
df2_WQ_temp2$System[which(df2_WQ_temp2$System=="SEP")] <- systems[i]

}

##df2_WQ() <- df2_WQ()[which((df2_WQ()$SampleType=="In" | df2_WQ()$SampleType=="PoreWater" | df2_WQ()$SampleType=="Out")),]
# create df with mean and sd as plot source data
df2_WQ_temp2 <- select(df2_WQ_temp2, -FlowDirection)
df2_WQ_temp2 <- mySummaryDf(df2_WQ_temp2)

# plot
wq_plot <- myGGPoreWQPlot(df2_WQ_temp2, "haha")
#wq_plot <- plot(seq(1,10,1), seq(2,20,2))
wq_plot <- myGGPoreWQPlot(df2_WQ_temp2, facet_var, "haha")


# remove temp data
rm(df2_WQ_temp1, df2_WQ_temp2)
}

# print plot
wq_plot

})
Expand Down

0 comments on commit 22a42e0

Please sign in to comment.