Skip to content

Commit

Permalink
Merge pull request #61 from Plant-Functional-Trait-Course/next_version
Browse files Browse the repository at this point in the history
Next version
  • Loading branch information
jogaudard authored Sep 3, 2024
2 parents 8e11081 + 390b8da commit 32e3e19
Show file tree
Hide file tree
Showing 16 changed files with 10,928 additions and 10,876 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: fluxible
Title: Ecosystem Gas Fluxes Calculations for Closed Loop Chamber Setup
Version: 0.0.2
Date: 2024-08-28
Version: 0.0.3
Date: 2024-09-03
Authors@R:
c(person(given = "Joseph", family = "Gaudard", , "joseph.gaudard@pm.me", role = c("aut", "cre"),
comment = c(ORCID = "0000-0002-6989-7624")),
Expand Down
4 changes: 4 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@ importFrom(ggplot2,geom_point)
importFrom(ggplot2,geom_text)
importFrom(ggplot2,ggplot)
importFrom(ggplot2,ggsave)
importFrom(ggplot2,guide_legend)
importFrom(ggplot2,guides)
importFrom(ggplot2,labs)
importFrom(ggplot2,scale_color_manual)
importFrom(ggplot2,scale_linetype_manual)
importFrom(ggplot2,scale_x_datetime)
importFrom(ggplot2,theme_bw)
importFrom(ggplot2,ylim)
Expand All @@ -58,6 +61,7 @@ importFrom(stringr,str_c)
importFrom(tidyr,drop_na)
importFrom(tidyr,fill)
importFrom(tidyr,nest)
importFrom(tidyr,pivot_longer)
importFrom(tidyr,pivot_wider)
importFrom(tidyr,replace_na)
importFrom(tidyr,unnest)
Expand Down
8 changes: 4 additions & 4 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# fluxible 0.0.2
# fluxible 0.0.3

* Unit choices in flux_calc
* plot_area can be a variable in flux_calc
* flux_fitting with exponential model works when concentration data are missing in the middle of the measurement
* All plots are colored the same (colors code for raw condentration data points and fit and slope in black)
* Legend for line types in plots
* Plot subtitles indicating the fit type
25 changes: 20 additions & 5 deletions R/flux_plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,17 @@
#' @importFrom dplyr rename select distinct mutate
#' @importFrom ggplot2 ggplot aes geom_point geom_line scale_color_manual
#' scale_x_datetime ylim facet_wrap labs geom_text theme_bw ggsave
#' scale_linetype_manual guides guide_legend
#' @importFrom ggforce facet_wrap_paginate n_pages
#' @importFrom purrr quietly
#' @importFrom progress progress_bar
#' @examples
#' data(slopes0_flag)
#' flux_plot(slopes0_flag, output = "print_only")
#' flux_plot(slopes0_flag)
#' data(slopes30lin_flag)
#' flux_plot(slopes30lin_flag, output = "print_only")
#' flux_plot(slopes30qua_flag, output = "print_only")
#' flux_plot(slopes30lin_flag)
#' data(slopes30qua_flag)
#' flux_plot(slopes30qua_flag)
#' @export

flux_plot <- function(slopes_df,
Expand Down Expand Up @@ -169,6 +171,12 @@ flux_plot <- function(slopes_df,
message("Plotting in progress")

f_plot <- f_plot +
geom_line(
aes(y = .data$fit, linetype = .data$linetype),
linewidth = 0.3,
na.rm = TRUE,
show.legend = TRUE
) +
scale_color_manual(values = c(
"cut" = ((color_cut)),
"ok" = ((color_ok)),
Expand All @@ -178,6 +186,10 @@ flux_plot <- function(slopes_df,
"weird_flux" = ((color_discard)),
"force_ok" = ((color_ok))
)) +
scale_linetype_manual(values = c(
"fit" = "longdash",
"slope" = "dashed"
)) +
scale_x_datetime(
date_breaks = ((f_date_breaks)), minor_breaks = ((f_minor_breaks)),
date_labels = ((f_date_labels))
Expand All @@ -188,10 +200,13 @@ flux_plot <- function(slopes_df,
) +
labs(
title = "Fluxes quality assessment",
subtitle = paste(fit_type, "model"),
x = "Datetime",
y = "Concentration",
colour = "Quality flags"
)
colour = "Quality flags",
linetype = "Fits"
) +
guides(color = guide_legend(override.aes = list(linetype = 0)))

if (((output)) == "print_only") {
return(f_plot)
Expand Down
24 changes: 11 additions & 13 deletions R/flux_plot_exp.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#' @importFrom ggforce facet_wrap_paginate n_pages
#' @importFrom purrr quietly
#' @importFrom grDevices pdf dev.off
#' @importFrom tidyr pivot_longer



Expand All @@ -26,7 +27,16 @@ flux_plot_exp <- function(slopes_df,
cut_arg = ((cut_arg))
)


slopes_df <- slopes_df |>
rename(
fit = "f_fit",
slope = "f_fit_slope"
) |>
pivot_longer(
cols = c("fit", "slope"),
names_to = "linetype",
values_to = "fit"
)



Expand All @@ -38,18 +48,6 @@ flux_plot_exp <- function(slopes_df,
size = 0.2,
na.rm = TRUE
) +
geom_line(
aes(y = .data$f_fit),
linetype = "longdash",
linewidth = 0.3,
na.rm = TRUE
) +
geom_line(
aes(y = .data$f_fit_slope),
linetype = "dashed",
linewidth = 0.2,
na.rm = TRUE
) +
geom_text(
aes(x = .data$f_start, y = ((y_text_position)), label = .data$print_col),
vjust = 0, hjust = "inward",
Expand Down
10 changes: 5 additions & 5 deletions R/flux_plot_lin.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ flux_plot_lin <- function(slopes_df,
cut_arg = ((cut_arg))
)

slopes_df <- slopes_df |>
mutate(
fit = .data$f_fit,
linetype = "fit"
)

plot_lin <- slopes_df |>
ggplot(aes(.data$f_datetime)) +
Expand All @@ -31,11 +36,6 @@ flux_plot_lin <- function(slopes_df,
size = 0.2,
na.rm = TRUE
) +
geom_line(
aes(y = .data$f_fit),
linetype = "longdash",
na.rm = TRUE
) +
geom_text(
aes(
x = .data$f_start, y = ((y_text_position)),
Expand Down
38 changes: 30 additions & 8 deletions R/flux_plot_quadratic.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,44 @@
#' @importFrom ggforce facet_wrap_paginate n_pages
#' @importFrom purrr quietly
#' @importFrom grDevices pdf dev.off
#' @importFrom tidyr pivot_longer



flux_plot_quadratic <- function(slopes_df,
y_text_position = 500,
cut_arg = "cut") {
plot_quadratic <- slopes_df |>
flux_plot_lin(
y_text_position = ((y_text_position)),
cut_arg = ((cut_arg))
param_df <- flux_param_lm(((slopes_df)), cut_arg = ((cut_arg)))

slopes_df <- flux_plot_flag(((slopes_df)),
((param_df)),
cut_arg = ((cut_arg))
)

slopes_df <- slopes_df |>
rename(
fit = "f_fit",
slope = "f_fit_slope"
) |>
pivot_longer(
cols = c("fit", "slope"),
names_to = "linetype",
values_to = "fit"
)

plot_quadratic <- plot_quadratic +
geom_line(
aes(y = .data$f_fit_slope, color = .data$f_quality_flag),
linetype = "dashed",
plot_quadratic <- slopes_df |>
ggplot(aes(.data$f_datetime)) +
theme_bw() +
geom_point(aes(y = .data$f_conc, color = .data$f_quality_flag),
size = 0.2,
na.rm = TRUE
) +
geom_text(
aes(
x = .data$f_start, y = ((y_text_position)),
label = .data$print_col
),
vjust = 0, hjust = "inward",
na.rm = TRUE
)

Expand Down
Binary file modified man/figures/README-plot_exp_cut-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-plot_exp_qua_lin-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-plot_exp_qua_lin-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-plot_exp_qua_lin-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-plot_lin_cut-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-plot_qua_cut-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 4 additions & 3 deletions man/flux_plot.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 32e3e19

Please sign in to comment.