{"id":27948257,"url":"https://github.com/const-ae/exactplot","last_synced_at":"2025-08-16T13:51:28.049Z","repository":{"id":278759629,"uuid":"931488682","full_name":"const-ae/exactplot","owner":"const-ae","description":"Produce scientific figures in R that look exactly how you want","archived":false,"fork":false,"pushed_at":"2025-02-26T11:47:21.000Z","size":369,"stargazers_count":16,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-07T14:57:07.336Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/const-ae.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-12T11:12:26.000Z","updated_at":"2025-03-29T13:33:14.000Z","dependencies_parsed_at":"2025-02-21T15:34:11.107Z","dependency_job_id":null,"html_url":"https://github.com/const-ae/exactplot","commit_stats":null,"previous_names":["const-ae/exactplot"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/const-ae%2Fexactplot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/const-ae%2Fexactplot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/const-ae%2Fexactplot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/const-ae%2Fexactplot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/const-ae","download_url":"https://codeload.github.com/const-ae/exactplot/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252902635,"owners_count":21822257,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-05-07T14:57:12.198Z","updated_at":"2025-08-16T13:51:27.687Z","avatar_url":"https://github.com/const-ae.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\n```\n\n# exactplot\n\n\u003c!-- badges: start --\u003e\n\u003c!-- badges: end --\u003e\n\nThe goal of `exactplot` is to produce millimeter-exact figure layouts and annotate your plots with the full power of Latex. `exactplot` wraps around [`tikzDevice`](https://daqana.github.io/tikzDevice/) and provides utility functions to compose grid plots (e.g., `ggplot2` output, but not base plots).\n\n## Disclaimer\n\nThis is a *work-in-progress* package and mainly serves as a collection of scripts that I have used in my past papers to produce my scientific figures. I currently do not plan to release it on CRAN and I am only planning to add features if I need them for my work. If you would like to see some feature included, please open a pull request, or feel free to fork the package.\n\n## Installation\n\nYou can install the development version of `exactplot` from Github:\n\n``` r\ndevtools::install_github(\"const-ae/exactplot\")\n```\n\nYou might need to install additional fonts. By default, `exactplot` uses the [IBM Plex](https://github.com/IBM/plex) font family. On Mac, you can install them using brew.\n\n``` shell\nbrew install --cask font-ibm-plex-sans font-ibm-plex-mono font-ibm-plex-math\n```\n\n## Example\n\n```{r, eval=FALSE}\nlibrary(exactplot)\nlibrary(tidyverse)\nlibrary(palmerpenguins)\n```\n```{r, include=FALSE}\ndevtools::load_all(\".\")\nlibrary(tidyverse)\nlibrary(palmerpenguins)\n```\n\nThe `xp_init` function sets consistent fonts and font sizes, adds additional packages to the `options(\"tikzLatexPackages\")`, and sets the default `ggplot2` theme. The default font sizes are available through the `xp` object. This is needed when you, want to use larger or smaller text in `geom_text()` (remember to change the `size.unit = \"pt\"`).\n\n```{r}\nxp_init()\nxp$fontsize\n```\n\n\nMake some simple example plots.\n\n```{r, paged.print=FALSE}\nscatter_plot \u003c- penguins |\u003e\n  mutate(label = paste0(species, \" (\", island, \", $\", year,\"$)\")) |\u003e\n  ggplot(aes(x = flipper_length_mm, y = bill_length_mm)) +\n    geom_point(aes(color = species), show.legend = FALSE) +\n    geom_label(data = \\(x) slice_max(x, bill_length_mm, by = species), \n               aes(label = label, hjust = ifelse(flipper_length_mm \u003c 200, 0, 1)), vjust = -0.2) +\n    labs(x = \"Flipper length in $10^{-3}$ m\", y = \"Bill length in $10^{-3}$ m\") +\n    coord_cartesian(clip = \"off\")\n\nbeak_lengths \u003c- penguins |\u003e\n  ggplot(aes(x = bill_length_mm)) +\n   geom_density(aes(fill = species), alpha = 0.7 ) +\n   labs(x = \"Bill length in $10^{-3}$ m\")\n```\n\n\nCombine the two plots with some additional annotations. If you call this function without specifying the filename, you get a quick preview without the latex rendering. By default, `exactplot` uses LuaLatex for rendering, because of its superior font support.\n\n```{r}\nxp_compose_plots(\n  xp_text(\"Welcome to \\\\texttt{exactplot} with \\\\LaTeX{} support\", x = 1, y = 2, \n          fontsize = xp$fontsize_large, fontface = \"bold\"),\n  xp_text(\"A) Flipper length vs.\\\\ beak size\", x = 1, y = 8),\n  xp_plot(scatter_plot, x = 0, y = 12, width = 80, height = 40),\n  \n  xp_text(\"B) Beak sizes\", x = 84, y = 8),\n  xp_plot(beak_lengths, x = 82, y = 12, width = 58, height = 40),\n  xp_text(\"$\\\\textrm{density}(x) = \\\\frac{1}{n\\\\sigma}\\\\frac{1}{\\\\sqrt{2\\\\pi}}\\\\sum_{i=1}^N{\\\\exp\\\\left(\\\\frac{-(x-x_i)^2}{2\\\\sigma^2}\\\\right)}$\",\n           x = 99, y = 12, fontsize = xp$fontsize_small),\n  \n  width = 140, height = 52,\n  keep_tex_file = FALSE, filename = \"man/example.pdf\"\n)\n```\n\n\n\nDisplay the output:\n\n```{r}\nprint(magick::image_read_pdf(\"man/example.pdf\", density = 600), info = FALSE)\n```\n\n# Load additional Latex packages\n\nThe `\\xleftrightarrow` is defined in the `mathtools` Latex package. You can load it by calling `xp_add_latex_package`.\n\n```{r}\nxp_add_latex_package(\"mathtools\")\n\nadv_label_pl \u003c- scatter_plot +\n  labs(x = \"Smaller $\\\\xleftrightarrow[\\\\text{[cm]}]{\\\\text{\\\\quad Flipper length\\\\quad}}$ Larger\") +\n  theme(axis.title.x = element_text(margin = margin(4, 0, 0, 0, \"pt\")))\n\nxp_compose_plots(\n  xp_plot(adv_label_pl, x = 0, y = 12, width = 80, height = 40),\n  \n  width = 140, height = 52, filename = \"man/example2.pdf\"\n)\n```\n\n\nDisplay the output:\n\n```{r}\nprint(magick::image_read_pdf(\"man/example2.pdf\", density = 600), info = FALSE)\n```\n\n\n# Session Info\n\n```{r}\nsessionInfo()\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fconst-ae%2Fexactplot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fconst-ae%2Fexactplot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fconst-ae%2Fexactplot/lists"}