| bgf_plot | R Documentation |
BGF visualizationA set of functions that allow advanced data visualization employing ggplot2 and plotly.
The two main functions are bgf_plot, which is a high end wrapper to produce frequently needed plots and plot_curve, which is offers more freedom during plot creation.
bgf_plot(x, type = "all", ...)
plot_curve(
x,
what,
color,
col = bgfanalyzer::BGF_defaultcolors,
coltitle = "Reactor:",
col_names = NULL,
title = NULL,
subtitle = NULL,
xlab = ggplot2::waiver(),
ylab = ggplot2::waiver(),
keep_excluded = TRUE,
interaction = FALSE
)
plot_product_curve(x, ...)
plot_production_curve(x, ...)
plot_rel_production_curve(x, ...)
plot_netProduct_by_Layout(
x,
col = bgfanalyzer::BGF_defaultcolors[2 + 3 * c(0:7)],
coltitle = "Layout:",
col_names = NULL,
title = NULL,
subtitle = NULL,
xlab = paste0("observation time [", x$ExpParam$timeScale, "s]"),
ylab = "net exhaust gas volume",
keep_excluded = TRUE,
interaction = FALSE
)
colplot_yield(
x,
hide = NULL,
Excluded = FALSE,
col = bgfanalyzer::BGF_defaultcolors[2 + 3 * c(0:7)],
coltitle = "Layout:",
col_names = NULL,
title = NULL,
subtitle = NULL,
yield_label = FALSE,
yield_label_pos = 100,
yield_unit = "Nml/gVS",
interaction = FALSE
)
boxplot_yield(
x,
timep = "all",
hide = NULL,
Excluded = FALSE,
col = bgfanalyzer::BGF_defaultcolors[2 + 3 * c(0:7)],
coltitle = "Layout:",
col_names = NULL,
title = NULL,
subtitle = NULL,
yield_label = FALSE,
yield_label_pos = 100,
yield_unit = "Nml/gVS",
interaction = FALSE
)
x |
a |
type |
a |
... |
further arguments passed to |
what |
the name of a ( |
color |
the name another column in the |
col |
a vector with colors to be used to differentiate between levels of the grouping variable. In the default setting, 24 colors are provided |
coltitle |
the title of the plot legend. default ='Reactor:' |
col_names |
default is |
title |
default is |
subtitle |
default is |
xlab |
can be used to change the default title of the x-axis. Default is waiver |
ylab |
can be used to change the default title of the y-axis. Default is waiver |
keep_excluded |
|
interaction |
|
hide |
default is |
Excluded |
|
yield_label |
|
yield_label_pos |
a |
yield_unit |
a |
timep |
a |
The main function for advanced data visualization purposes is bgf_plot.
It is a wrapper that successively calls plot_product_curve, plot_production_curve, plot_rel_production_curve, plot_netProduct_by_Layout, colplot_yield and boxplot_yield.
It stores the output of each function in a list which is returned
The second function, that allows advanced data visualization is plot_curve.
It can be used to draw a line plot from data in the BioGasData-layer of a BGF.
In this plot, the 'time' column representing the fermentation/ observation time will be on the x-axis.
The y-axis can be any other column of the BioGasData-layer and is specified via the 'what' argument.
Furthermore, it is required to provide a grouping variable in the 'color' argument.
If that grouping variable has more than 24 levels, the 'col' argument must be changed as in the default setting only 24 colors are available for plotting.
There exist several wrapper functions, that internally call plot_curve exist.
These are:
plot_product_curve: Produces a 'product' line plot. Argument 'what' set to 'product' and argument 'color' set to 'reactor'. Can be called via bgf_plot when 'type = "product"' or 'type = "all"'. In the later case, the plot is stored in a list with the label 'product_curve'.
plot_production_curve: Produces a 'production' line plot. Argument 'what' set to 'production' and argument 'color' set to 'reactor'. Can be called via bgf_plot when 'type = "production"' or 'type = "all"'. In the later case, the plot is stored in a list with the label 'production_curve'.
plot_rel_production_curve: Produces an inverted 'rel_production' line plot. Argument 'what' set to 'c(100-rel_production)' and argument 'color' set to 'reactor'. Can be called via bgf_plot when 'type = "relProduction"' or 'type = "all"'. In the later case, the plot is stored in a list with the label 'rel_production_curve'
The function plot_netProduct_by_Layout plots mean net gas curves per layout.
It will extract 'net_product' values from the BioGasData-layer and calculates a mean for each 'Layout' specified in the metaData-layer at each 'time' before drawing the line plot.
Can be called via bgf_plot when 'type = "netProduct"' or 'type = "all"'.
In the later case, the plot is stored in a list with the label 'net_product_curve'.
The function colplot_yield produces a col plot with reactor layouts on the x-axis and mean 'yield' values per layout on the y-axis.
It can be used if a yield summary was transferred to the metaData-layer using summarize_yield.
It will generate a column-plot with reactor layouts on the x-axis and mean yield values per layout on the y-axis.
With the default settings, fermentations that are marked as 'Excluded' in the metaData-layer will not be included in the plot.
The standard deviation around the mean value will be calculated and drawn as an errorbar if possible.
Can be called via bgf_plot when 'type = "yield_col"' or 'type = "all"'.
In the later case, the plot is stored in a list with the label 'yield_col'.
The function boxplot_yield produces a box plot with reactor layouts on the x-axis and and 'yield' values per layout on the y-axis.
The argument 'timep' can be used to specify how many observations will be used to draw the boxes.
In the default setting, 'all', all available observations for a layout will be used.
Alternatively, to select the final observations 'timep = "max"' can be set.
Furthermore any numeric that matches a value in the 'time' column of the BioGasData-layer can be passed to 'timep' to select the specific 'yield' value at that time.
Can be called via bgf_plot when 'type = "yield_box"' or 'type = "all"'.
In the later case, the plot is stored in a list with the label 'yield_box'.
either a single ggplot2 object or a list of ggplot2 objects
# create an example BGF
myBGF <- from_AMPTSV2_report(
ReactorLayout = c("2*Meso","Cellulose","2*S1 ctrl","2*S1 7d","2*S1 4d",
"2*S2 ctrl","2*S2 4d","2*S2 6d"),
BlankLabel = "Meso",
name = "myBGF",
ProcessTemp = 40,
InocToSubRatio = 2,
path = base::system.file("extdata","AMPTSV2.csv",package = "bgfanalyzer"))
# generate all plots for the BGF
Plots <- bgf_plot(myBGF)
# print 'product' curve
if(interactive()) Plots[["product_curve"]]
# print 'net product' curve
if(interactive()) Plots[["net_product_curve"]]
# print 'production' curve
if(interactive()) Plots[["production_curve"]]
# print 'relative production' curve
if(interactive()) Plots[["rel_production_curve"]]
# print 'yield' colplot
if(interactive()) Plots[["yield_col"]]
# print 'yield' boxplot
if(interactive()) Plots[["yield_box"]]
# in the following examples the same plots are produced by plot_curve and the respective wrappers
# plot 'product' curve
plot_curve(
x = myBGF,
what = product,
color = reactor,
ylab = "raw exaust gas volume",
xlab = paste0("observation time [",myBGF$ExpParam$timeScale,"]"))
if(interactive()) plot_product_curve(myBGF)
if(interactive()) bgf_plot(myBGF,type="product")
# plot 'production' curve
plot_curve(
x = myBGF,
what = production,
color = reactor,
ylab = "raw exaust gas flow",
xlab = paste0("observation time [",myBGF$ExpParam$timeScale,"s]"))
if(interactive()) plot_production_curve(myBGF)
if(interactive()) bgf_plot(myBGF,type="production")
# plot 'rel_production' curve(s)
plot_curve(
x = myBGF,
what = rel_production,
color = reactor,
ylab = "remaining gas production [%]",
xlab = paste0("observation time [",myBGF$ExpParam$timeScale,"s]"))
if(interactive()) plot_rel_production_curve(myBGF)
# Note: this curve is inverted so it starts at 100 %
if(interactive()) bgf_plot(myBGF,type="relProduction")
# plot mean net product by reactor layout
plot_netProduct_by_Layout(myBGF)
# create a col plot of the yield
colplot_yield(myBGF)
if(interactive()) bgf_plot(myBGF,type="yield_col")
# create a box plot of the 'yield'
boxplot_yield(myBGF)
if(interactive()) bgf_plot(myBGF,type="yield_box")
# create a box plot of the final 'yield'
boxplot_yield(myBGF,timep="max")
if(interactive()) bgf_plot(myBGF,type="yield_box",timep="max")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.