ggobi / ggally

R package that extends ggplot2
http://ggobi.github.io/ggally/
584 stars 119 forks source link

Proposal for Implementing ggcall into GGally for Enhanced Plot Reproducibility #498

Open Polkas opened 4 months ago

Polkas commented 4 months ago

Hello GGally Team,

I hope this message finds you well. I am a developer working on an enhancement tool called ggcall, designed to improve the transparency and reproducibility of ggplot2 visualizations by overwriting the ggplot and + operator functions. This tool enables full visibility of the plotting code even when ggplot2 is used within other functions, leveraging metaprogramming to ensure precise replication.

I have developed a fork of GGally where ggcall has been integrated successfully, and I would like to propose this addition to the main GGally repository. The integration has significantly enhanced the functionality of GGally by making the plot creation process fully transparent and reproducible. Integrating ggcall requires adding a new R script (small one file) to the GGally package and modifying the already overridden + operator from ggplot2 within GGally. Please check out the fork and https://github.com/Polkas/ggcall/blob/main/inst/ggally.R.

Benefits of Integrating ggcall into GGally:

Example Usage:

Here's how ggcall can be used with GGally:

remotes::install_github("https://github.com/Polkas/ggally")
library(GGally)
data(mtcars)
gg <- ggcorr(mtcars, method = "everything", label = TRUE)
gg_call <- ggcall(gg)
gg_call
# Optionally: Style the code with styler
# styler::style_text(deparse1(gg_call))
# Optional
# Access call environment and/or use it to evaluate the call
# as.list(ggcall_env(gg_call))
eval_ggcall(gg_call)
#'
data(iris)
gg <- ggscatmat(iris, color = "Species")
gg_call<- ggcall(gg)
gg_call
# Optionally: Style the code with styler
# styler::style_text(deparse1(gg_call))
# Optional
# Access call environment and/or use it to evaluate the call
# as.list(ggcall_env(gg_call))
eval_ggcall(gg_call)
#'
data(tips, package = "reshape")
# Not supported for ggmatrix like plots
gg <- ggduo(tips, mapping = ggplot2::aes(colour = sex), columnsX = 3:4, columnsY = 1:2)
# Will fail
# gg_call<- ggcall(gg)

Fork Repository: You can find the working implementation in my forked repository here: ggcall-GGally fork

I believe this enhancement will be a valuable addition to GGally. I am eager to hear your thoughts on this proposal and discuss any potential concerns you might have. Thank you for considering this integration. I look forward to your feedback.

Best regards, Maciej Nasinski