{"id":14069083,"url":"https://github.com/r-lib/gtable","last_synced_at":"2025-05-15T08:06:27.237Z","repository":{"id":2131947,"uuid":"3075216","full_name":"r-lib/gtable","owner":"r-lib","description":"The layout packages that powers ggplot2","archived":false,"fork":false,"pushed_at":"2025-04-25T08:58:59.000Z","size":5966,"stargazers_count":93,"open_issues_count":1,"forks_count":18,"subscribers_count":11,"default_branch":"main","last_synced_at":"2025-05-10T11:52:29.256Z","etag":null,"topics":["r"],"latest_commit_sha":null,"homepage":"https://gtable.r-lib.org","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/r-lib.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","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":"2011-12-30T16:08:43.000Z","updated_at":"2025-05-09T22:54:41.000Z","dependencies_parsed_at":"2023-07-05T19:02:39.131Z","dependency_job_id":"5fdcdcd8-ad9f-4bb3-ac22-09a0ba416b34","html_url":"https://github.com/r-lib/gtable","commit_stats":{"total_commits":190,"total_committers":11,"mean_commits":"17.272727272727273","dds":0.5526315789473684,"last_synced_commit":"c410a54ed331cb8480f39f2a7d32cce115c19f1d"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-lib%2Fgtable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-lib%2Fgtable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-lib%2Fgtable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-lib%2Fgtable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/r-lib","download_url":"https://codeload.github.com/r-lib/gtable/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254044467,"owners_count":22005167,"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":["r"],"created_at":"2024-08-13T07:06:35.616Z","updated_at":"2025-05-15T08:06:27.182Z","avatar_url":"https://github.com/r-lib.png","language":"R","funding_links":[],"categories":["R"],"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}\n#| label: setup\n#| include: false\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\nset.seed(42L)\noptions(width = 90)\n```\n\n# gtable \u003ca href=\"https://gtable.r-lib.org\"\u003e\u003cimg src=\"man/figures/logo.png\" align=\"right\" height=\"138\" /\u003e\u003c/a\u003e\n\n\u003c!-- badges: start --\u003e\n[![R-CMD-check](https://github.com/r-lib/gtable/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/r-lib/gtable/actions/workflows/R-CMD-check.yaml)\n[![CRAN status](https://www.r-pkg.org/badges/version/gtable)](https://CRAN.R-project.org/package=gtable)\n[![Codecov test coverage](https://codecov.io/gh/r-lib/gtable/graph/badge.svg)](https://app.codecov.io/gh/r-lib/gtable)\n[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable)\n\u003c!-- badges: end --\u003e\n\ngtable is a layout engine built on top of the grid package. It is used to abstract away the creation of (potentially nested) grids of viewports into which graphic objects can be placed. gtable makes it easy to ensure alignment of graphic elements and piecemeal compositions of complex graphics. gtable is the layout engine powering [ggplot2](https://ggplot2.tidyverse.org) and is thus used extensively by many plotting functions in R without being called directly.\n\n## Installation\n\nYou can install the released version of gtable from [CRAN](https://CRAN.R-project.org) with:\n\n``` r\ninstall.packages(\"gtable\")\n```\n\nor use the remotes package to install the development version from [GitHub](https://github.com/r-lib/gtable)\n\n```r\n# install.packages(\"pak\")\npak::pak(\"r-lib/gtable\")\n```\n\n## Example\nggplot2 uses gtable for laying out plots, and it is possible to access the gtable representation of a plot for inspection and modification:\n\n```{r}\n#| message: false\nlibrary(gtable)\nlibrary(ggplot2)\n\np \u003c- ggplot(mtcars, aes(mpg, disp)) + geom_point()\n\np_table \u003c- ggplotGrob(p)\n\np_table\n```\n\nA gtable object is a collection of graphic elements along with their placement in the grid and the dimensions of the grid itself. Graphic elements can span multiple rows and columns in the grid and be gtables themselves allowing for very complex automatically arranging layouts.\n\nA gtable object is itself a grob, and can thus be drawn using standard functions from the grid package:\n\n```{r}\n#| fig-alt: \u003e\n#|   A scatterplot of miles per gallon against displacement based on the mtcars\n#|   dataset. The plot is rendered by first converting the ggplot object to a\n#|   gtable and then plotting the gtable\nlibrary(grid)\ngrid.draw(p_table) # alternative use plot(p_table)\n```\n\nWhile most people will interact with gtable through ggplot2, it is possible to build a plot from the ground up.\n\n```{r}\n#| fig-alt: \u003e\n#|   A scatterplot of random numbers. The scatterplot is created by combining\n#|   separate grobs created with grid using gtable.\n# Construct some graphical elements using grid\npoints \u003c- pointsGrob(\n  x = runif(10),\n  y = runif(10),\n  size = unit(runif(10), 'cm')\n)\nxaxis \u003c- xaxisGrob(at = c(0, 0.25, 0.5, 0.75, 1))\nyaxis \u003c- yaxisGrob(at = c(0, 0.25, 0.5, 0.75, 1))\n\n# Setup the gtable layout\nplot \u003c- gtable(\n  widths = unit(c(1.5, 0, 1, 0.5), c('cm', 'cm', 'null', 'cm')),\n  heights = unit(c(0.5, 1, 0, 1), c('cm', 'null', 'cm', 'cm'))\n)\n\n# Add the grobs\nplot \u003c- gtable_add_grob(\n  plot,\n  grobs = list(points, xaxis, yaxis),\n  t = c(2, 3, 2),\n  l = c(3, 3, 2),\n  clip = 'off'\n)\n\n# Plot\ngrid.draw(plot)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fr-lib%2Fgtable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fr-lib%2Fgtable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fr-lib%2Fgtable/lists"}