Skip to content

Commit

Permalink
Added 'cowplot' dependency to convert gTree objects to ggplot
Browse files Browse the repository at this point in the history
  • Loading branch information
gavieira committed Dec 1, 2023
1 parent 257edd0 commit 7e9cb9d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Encoding: UTF-8
LazyData: true
RoxygenNote: 7.2.3
Imports:
cowplot,
dplyr,
ggplot2,
ggVennDiagram,
Expand Down
20 changes: 14 additions & 6 deletions R/06-plots_and_app.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Adding biblioverlap's logo to plots
#' Finalizing biblioverlap's plots
#'
#' @description
#' Helper function to add biblioverlap's logo to its plots. Except for `logo_path` and `alpha`, all its parameters are compatible with [`grid::grid.raster`]. Check its documentation for more info.
#' Helper function to finalize biblioverlap's plots. It basically adds (when `add_logo = TRUE`) the package's logo to the plot passed as argument. Except for `logo_path`, `add_logo` and `alpha`, all its parameters are compatible with [`grid::grid.raster`]. Check its documentation for more info.
#'
#' @param plot - plot to add logo
#' @param logo_path - path to logo .png file
Expand Down Expand Up @@ -29,7 +29,6 @@ add_logo_to_plot <- function(plot,
interpolate = TRUE,
... ) {


# Set up the layout for the main plot and logo
layout <- grid::grid.layout(nrow = 1, ncol = 1)
#
Expand Down Expand Up @@ -63,8 +62,16 @@ add_logo_to_plot <- function(plot,
# Reset the viewport
grid::popViewport(2)

return( grid::grid.grab(wrap.grobs = TRUE ) )
#Return the combined graphical object
#Generate combined plot
combined_plot <- grid::grid.grab(wrap.grobs = TRUE )

#Generate final plot
final_plot <- cowplot::ggdraw() +
cowplot::draw_plot(combined_plot)


#Return the final graphical object
return( final_plot )
}


Expand Down Expand Up @@ -140,7 +147,7 @@ plot_venn <- function(db_list, ...) {
venn <- ggVennDiagram::ggVennDiagram(uuid, ...) +
ggplot2::scale_fill_gradient(low = "#A7C7E7", high = "#08306B") +
ggplot2::scale_x_continuous(expand = ggplot2::expansion(mult = .2))
#return ( venn )

return ( add_logo_to_plot(venn) )
}

Expand Down Expand Up @@ -171,6 +178,7 @@ plot_upset <- function(db_list, ...) {
shade.color = "steelblue",
matrix.color = "#08306B",
...)

return ( add_logo_to_plot(upset) )
}

Expand Down
6 changes: 5 additions & 1 deletion man/plot_matching_summary.Rd

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

0 comments on commit 7e9cb9d

Please sign in to comment.