{"id":20814361,"url":"https://github.com/nicolash2/ggbrace","last_synced_at":"2025-10-11T14:42:45.897Z","repository":{"id":53143631,"uuid":"340401157","full_name":"NicolasH2/ggbrace","owner":"NicolasH2","description":"curly braces in ggplot2.","archived":false,"fork":false,"pushed_at":"2025-07-14T10:36:19.000Z","size":1351,"stargazers_count":13,"open_issues_count":0,"forks_count":5,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-11T14:42:43.372Z","etag":null,"topics":["brace","braces","bracket","ggplot","ggplot2","graph","graphs","plot","r"],"latest_commit_sha":null,"homepage":"https://github.com/Solatar/ggbrace","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/NicolasH2.png","metadata":{"files":{"readme":"README.md","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-02-19T14:54:21.000Z","updated_at":"2025-07-08T18:29:51.000Z","dependencies_parsed_at":"2024-11-13T21:35:28.543Z","dependency_job_id":"db667bc2-0d68-47a6-a44d-76a02e0fdfd3","html_url":"https://github.com/NicolasH2/ggbrace","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/NicolasH2/ggbrace","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NicolasH2%2Fggbrace","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NicolasH2%2Fggbrace/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NicolasH2%2Fggbrace/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NicolasH2%2Fggbrace/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NicolasH2","download_url":"https://codeload.github.com/NicolasH2/ggbrace/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NicolasH2%2Fggbrace/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279007459,"owners_count":26084313,"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","status":"online","status_checked_at":"2025-10-11T02:00:06.511Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["brace","braces","bracket","ggplot","ggplot2","graph","graphs","plot","r"],"created_at":"2024-11-17T21:15:52.441Z","updated_at":"2025-10-11T14:42:45.889Z","avatar_url":"https://github.com/NicolasH2.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ggbrace\n\nAn [R](https://www.r-project.org) package that draws curly braces in [ggplot2](https://ggplot2.tidyverse.org/).\n\n# Table of contents\n- [Updates](#Updates)\n- [Installation](#Installation)\n- [Default braces](#Plotting-braces)\n- [Labels \u0026 Modifications](#Labels-\u0026-Modifications)\n- [Outside of plotting area](#Outside-of-plotting-area)\n- [Discrete values](#Discrete-values)\n\n\u003cimg src=\"readme_files/frontImage.png\"/\u003e\n\n# Updates\nVersion 0.1.1 (Feb 2024) of ggbrace removed the original `geom_brace` function, which plots braces within the confines of the x-y-values. The same functionality can now be achieved with `stat_brace( outside = FALSE )`. Additionally, the text functionality is now its own function `stat_bracetext` which allows for more customization of the text using the same arguments that would be used in `geom_text` or `geom_label`. By default `stat_brace` uses `geom=\"text\"` which can be changed e.g. by `stat_brace(geom=\"label\")`.\n\n\n# Installation\nInstall the package from CRAN\n``` r\ninstall.packages(\"ggbrace\")\n```\nor from this git repository:\n``` r\ndevtools::install_github(\"nicolash2/ggbrace\")\n```\n\n# Plotting braces\nThe new version of ggbrace uses only `stat_brace` to automatically enclose data points. `stat_bracetext` is used to generate fitting text.\n\nIn our example we use the iris data to create a dotplot. Then we look at how each of the three different modes draws braces to that plot.\n\n``` r\nlibrary(ggplot2)\nlibrary(ggbrace)\ndata(iris)\n\nplt \u003c- ggplot(iris, aes(x=Sepal.Length, y=Sepal.Width, color=Species, label=Species)) + \n  geom_point() +\n  theme_classic() +\n  theme(legend.position=\"none\")\n\nplt + stat_brace()\n```\n\n\u003cimg src=\"readme_files/default_braces.png\"/\u003e\n\n# Labels \u0026 Modifications\n\n## Labels\n\nWe can add labels to the braces. For that the `stat_bracetext` is used.\n\n``` r\nplt + \n  stat_brace() +\n  stat_bracetext()\n```\n\u003cimg src=\"readme_files/braces_with_text.png\"/\u003e\n\nWe can modify the text in the same way we would modify other text in ggplot. We can also switch between different text geoms (e.g. `geom=label`).\n\n``` r\nplt + \n  stat_brace() +\n  stat_bracetext(size=6, angle=15, fontface=\"bold\")\n```\n\u003cimg src=\"readme_files/custom_text.png\"/\u003e\n\n## Rotation\n\nWe can rotate the braces by 90, 180 or 270 degrees via the `rotate` argument. Note that any changes in `stat_brace` also have to be made in `stat_bracetext` so that the text appears at the right position\n\n``` r\nplt + \n  stat_brace(rotate = 90) + \n  stat_bracetext(rotate = 90)\n```\n\n\u003cimg src=\"readme_files/custom_rotation.png\"/\u003e\n\n## Location\n\nBy default, the location of the brace is beside the data points by default. We can change that by setting the paramter `outside` to `FALSE`.\n\n```r\nplt + stat_brace(outside = FALSE)\n```\n\u003cimg src=\"readme_files/inside.png\"/\u003e\n\nBy default, braces have a position and shape that is calculated based on their data points.The position can be changed with the parameters `distance` (to the data points) and `outerstart` (in the coordinate system). The width of the braces can be set with the `width` argument (absolute coordinate system units), while the bending of the brace can be set with `bending` (number from 0 to 1).\n\n```r\nplt + stat_brace(distance = 2) # the braces are put at a defined distance to the last data point of their group\nplt + stat_brace(outerstart = 5) # all braces are put at the same position\nplt + stat_brace(outerstart = 5, width = 1) # all braces get the same width\nplt + stat_brace(outerstart = 5, width = 1, bending = 0.1) # all braces get the same curvature\n```\n\u003cimg src=\"readme_files/custom_distance.png\"/\u003e\n\n# Outside of plotting area\n\nTo vizualize the brace outside of the plotting area, we can simply use two ggplot2 functions. \n- `coord_cartesian` needs to be mentioned with x and/or y range of the plotting area and the parameter `clip=\"off\"` to allow plotting of objects outside of that area.\n- within the `theme` function, `plot.margin` needs to be set to expand the outside area. This happens with 4 numbers (above, right, below, left). This can best be achieved with the `\"npc\"` unit, as it reflects the plot units and is therefore maintained independent of the pixels, cm, etc. Other units can be seen with ?unit (under grid).\n```r\nplt + stat_brace(outerstart = 4.5) + \n  coord_cartesian(y=range(iris$Sepal.Width), clip = \"off\") + #for the range just use the data for the respective axis\n  theme(plot.margin = unit(c(0.25, 0.11, 0.11, 0.11), units=\"npc\"))\n```\n\u003cimg src=\"readme_files/outside.png\"/\u003e\n\n# New Features - only in github version\n\n## Discrete/Categorical axis\n\nUse `discreteAxis=TRUE` to ensure the braces embrace the category.\n\n```r\ndf \u003c- iris\ndf$Group \u003c- substring(iris$Species,1,1)\nggplot(df, aes(x=Species, y=Sepal.Length, group=Group)) +\n    geom_jitter() +\n    stat_brace(discreteAxis=TRUE)\n```\n\n\u003cimg src=\"readme_files/brace_discreteAxis.png\"/\u003e\n\n## Square brackets\n\nUse `bracketType=\"square\"` to produce square brackets instead of curly ones. The bracket have the same width as the curly ones in order to comply with the text. Use the `width` parameter to adjust their size.\n\n```r\nplt + stat_brace(bracketType=\"square\", width=.2)\n```\n\n\u003cimg src=\"readme_files/brace_squareBrackets.png\"/\u003e\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnicolash2%2Fggbrace","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnicolash2%2Fggbrace","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnicolash2%2Fggbrace/lists"}