{"id":13712081,"url":"https://github.com/osthomas/ggtikz","last_synced_at":"2025-10-22T03:28:18.833Z","repository":{"id":45692451,"uuid":"396373901","full_name":"osthomas/ggtikz","owner":"osthomas","description":"ggtikz: Add TikZ annotations with absolute data or relative plot coordinates to ggplots","archived":false,"fork":false,"pushed_at":"2024-06-15T10:29:06.000Z","size":1072,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-13T22:35:27.361Z","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/osthomas.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","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":"2021-08-15T14:13:33.000Z","updated_at":"2024-06-15T10:29:09.000Z","dependencies_parsed_at":"2024-01-07T01:41:04.049Z","dependency_job_id":"2418fea3-583e-49ec-8031-c18835d6f081","html_url":"https://github.com/osthomas/ggtikz","commit_stats":{"total_commits":65,"total_committers":3,"mean_commits":"21.666666666666668","dds":0.3384615384615385,"last_synced_commit":"6e10301f1b6a908efefd4d215a7d45fe10775751"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/osthomas%2Fggtikz","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/osthomas%2Fggtikz/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/osthomas%2Fggtikz/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/osthomas%2Fggtikz/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/osthomas","download_url":"https://codeload.github.com/osthomas/ggtikz/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252772277,"owners_count":21801897,"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":"2024-08-02T23:01:14.711Z","updated_at":"2025-10-22T03:28:18.758Z","avatar_url":"https://github.com/osthomas.png","language":"R","funding_links":[],"categories":["Plot layers"],"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}\n    # Process .pdf generated by tikzDevice to .png\n    pdf2png \u003c- function(path, options) {\n        if (!grepl(\".pdf$\", path)) return(path)\n        outpath \u003c- gsub(\".pdf\", \".png\", path)\n        texpath \u003c- gsub(\".pdf\", \".tex\", path)\n        img \u003c- magick::image_read(path, density=300)\n        magick::image_write(img, outpath, format=\"png\")\n        unlink(path)\n        unlink(texpath)\n        return(outpath)\n    }\n\n    knitr::opts_chunk$set(\n        collapse = TRUE,\n        comment = \"#\u003e\",\n        fig.path = \"man/figures/README-\",\n        fig.width = 3,\n        fig.height = 3,\n        fig.show = \"hold\",\n        out.width=\"50%\",\n        dev = \"tikz\",\n        external = TRUE,\n        fig.process = pdf2png\n    )\n\n    library(tikzDevice)\n    library(ggplot2)\n    library(ggtikz)\n    options(tikzLatexPackages = c(getOption(\"tikzLatexPackages\"), \"\\\\usetikzlibrary{calc}\"))\n```\n\n# ggtikz\n\n\u003c!-- badges: start --\u003e\n[![CRAN status](https://www.r-pkg.org/badges/version/ggtikz)](https://CRAN.R-project.org/package=ggtikz)\n[![codecov](https://codecov.io/gh/osthomas/ggtikz/branch/main/graph/badge.svg?token=0LPNGPFO5Z)](https://app.codecov.io/gh/osthomas/ggtikz)\n[![R-CMD-check](https://github.com/osthomas/ggtikz/workflows/R-CMD-check/badge.svg)](https://github.com/osthomas/ggtikz/actions)\n\u003c!-- badges: end --\u003e\n\nggtikz allows you to annotate plots created using\n[ggplot2](https://ggplot2.tidyverse.org/)\nwith arbitrary TikZ code when rendering\nthem with the [tikzDevice](https://CRAN.R-project.org/package=tikzDevice).\nThe annotations can be made using data coordinates, or with coordinates relative\nto a specified panel or the whole plot.\n\nPlots with multiple panels (via `facet_grid()` or `facet_wrap()`) are supported.\n\nFor a few examples, see the [examples vignette](https://github.com/osthomas/ggtikz/blob/devel/doc/examples.pdf).\n\n## Installation\n\nYou can install the latest ggtikz release from CRAN with:\n\n``` {r, eval = FALSE}\ninstall.packages(\"ggtikz\")\n```\n\nOr get the development version from GitHub:\n\n``` {r, eval = FALSE}\n# install.packages(\"devtools\")\ndevtools::install_github(\"osthomas/ggtikz\", ref = \"devel\")\n```\n\n\u003c!-- ## New in Devel\n[![codecov (devel)](https://codecov.io/gh/osthomas/ggtikz/branch/devel/graph/badge.svg?token=0LPNGPFO5Z)](https://codecov.io/gh/osthomas/ggtikz)\n[![R-CMD-check (devel)](https://github.com/osthomas/ggtikz/workflows/R-CMD-check/badge.svg?branch=devel)](https://github.com/osthomas/ggtikz/actions)\n --\u003e\n\n## Basic Usage\n\n1. Create  a ggplot.\n2. Add annotations with `ggtikz()`.\n\n```{r basic-usage}\nlibrary(ggplot2)\nlibrary(ggtikz)\n\np \u003c- ggplot(mtcars, aes(disp, mpg)) + geom_point() # 1.\n## tikz(\"plot.tikz\")\nggtikz(p,\n    \"\\\\fill[red] (0.5,0.5) circle (5mm);\",\n    xy = \"panel\", panelx = 1, panely = 1)\n## dev.off()\n## Render with LaTeX ...\n```\n\n## Advanced Usage\n\n1. Create a ggplot.\n2. Create a ggtikz canvas from the plot with `ggtikzCanvas()`.\n3. Create ggtikz annotations with `ggtikzAnnotation()`.\n4. Add the annotations to the canvas.\n5. Draw the plot and the annotations using tikzDevice.\n\n```{r advanced-usage}\nlibrary(ggplot2)\nlibrary(ggtikz)\n\np \u003c- ggplot(mtcars, aes(disp, mpg)) + geom_point()  # 1.\ncanvas \u003c- ggtikzCanvas(p)                           # 2.\nannot1 \u003c- ggtikzAnnotation(                         # 3.\n    \"\n    \\\\draw (0,0) -- (1,1);\n    \\\\draw (0,1) -- (1,0);\n    \\\\fill[red] (0.5,0.5) circle (5mm);\n    \",\n    xy = \"panel\", panelx = 1, panely = 1\n)\nannot2 \u003c- ggtikzAnnotation(                          # 3.\n    \"\\\\draw[\u003c-] (400,20) -- ++(0,3) node[at end, anchor=south] {(400,20)};\",\n    xy = \"data\", panelx = 1, panely = 1\n)\n\n## tikz(\"plot.tikz\")\np                                                   # 4. + 5.\ncanvas + annot1 + annot2\n## dev.off()\n## Render with LaTeX ...\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fosthomas%2Fggtikz","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fosthomas%2Fggtikz","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fosthomas%2Fggtikz/lists"}