Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

switch from xgx_annotate_filenames to labs(caption = caption) for simplicity/transparency #55

Open
iamstein opened this issue Jun 16, 2023 · 1 comment

Comments

@iamstein
Copy link
Member

iamstein commented Jun 16, 2023

At the top of my code, I have something like:

caption = paste(c("Parent Dir: dosefindingtoolbox/Rmarkdown",
                  "Rmarkdown: Efficacy_Data_Overview_Plots.Rmd",
                  "Output: Efficacy_Data_Overview_Plots.html",
                  paste0("Timestamp: ", Sys.time())),
                collapse = "\n")

And then when I’m building the graphic, I have this:

g = g + labs(caption = caption)

Or another idea is at the top of the code to type something like

gcaption = theme(plot.caption = element_text(hjust = 0.5)) +
      labs(caption = paste0(dirs$top.local,"\n",
                            file.path(dirs$scripts.local, Rname),"\n",
                            file.path(dirs$scripts.local, Rmd_In),"\n",
                            file.path(dirs$results.local, Rmd_Out)))

then, later on in the code you can use

g = g + gcaption
@iamstein
Copy link
Member Author

iamstein commented Jul 1, 2023

Here's the implementation of the above that is working properly.

Rmd_name = "Filename.Rmd"
caption = paste(c(dirs$parent_dir, 
                  Rmd_name,
                  str_replace(Rmd_name, ".Rmd$", ".html"),
                  paste(Sys.time())),
                  collapse = "\n")
ggcaption = list(labs(caption = caption),
                 theme(plot.caption = element_text(hjust = 0.5)))

ggplot(cars, aes(x=speed, y=dist)) + geom_point() + ggcaption

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant