{"id":13712104,"url":"https://github.com/coolbutuseless/ggthreed","last_synced_at":"2025-03-21T12:30:59.760Z","repository":{"id":95359615,"uuid":"157353563","full_name":"coolbutuseless/ggthreed","owner":"coolbutuseless","description":"3d geoms and stats for ggplot","archived":false,"fork":false,"pushed_at":"2019-04-03T11:01:11.000Z","size":5390,"stargazers_count":47,"open_issues_count":1,"forks_count":4,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-03-01T06:11:12.440Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/coolbutuseless.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}},"created_at":"2018-11-13T09:24:21.000Z","updated_at":"2024-12-16T19:30:11.000Z","dependencies_parsed_at":"2023-07-04T20:17:00.151Z","dependency_job_id":null,"html_url":"https://github.com/coolbutuseless/ggthreed","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coolbutuseless%2Fggthreed","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coolbutuseless%2Fggthreed/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coolbutuseless%2Fggthreed/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coolbutuseless%2Fggthreed/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coolbutuseless","download_url":"https://codeload.github.com/coolbutuseless/ggthreed/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244135909,"owners_count":20403798,"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.971Z","updated_at":"2025-03-21T12:30:59.302Z","avatar_url":"https://github.com/coolbutuseless.png","language":"R","funding_links":[],"categories":["Plot layers","R","ggplot"],"sub_categories":["Additional Plot Types"],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r setup, include = FALSE}\nsuppressPackageStartupMessages({\n  library(dplyr)\n  library(ggplot2)\n  library(threed)\n  library(ggthreed)\n  library(threed)\n})\n\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\n```\n\n# ggthreed - 3d geoms and stats for ggplot2\u003cimg src=\"man/figures/logo-with-pause.gif\" align=\"right\"/\u003e\n\n[![Travis build status](https://travis-ci.org/coolbutuseless/ggthreed.svg?branch=master)](https://travis-ci.org/coolbutuseless/ggthreed)\n[![AppVeyor build status](https://ci.appveyor.com/api/projects/status/github/coolbutuseless/ggthreed?branch=master\u0026svg=true)](https://ci.appveyor.com/project/coolbutuseless/ggthreed)\n![](https://img.shields.io/badge/lifecycle-alpha-orange.svg)\n\n[`ggthreed`](https://github.com/coolbutuseless/ggthreed) is a collection of [`ggplot2`](https://github.com/tidyverse/ggplot2) \ngeoms which use the [`threed`](https://github.com/coolbutuseless/threed) library.\n\nWhat's in the box:\n\n* `geom_threedpie()` for creating 3d pie charts.\n    * **I am fully aware of the crimes against visualisation I am committing here.**\n* `stat_anaglyph()` for creating red-blue anaglyph images\n\n\n\n## Installation\n\nYou can install from github\n\n```{r eval=FALSE}\n# install.packages(\"devtools\")\ndevtools::install_github(\"coolbutuseless/threed\")\ndevtools::install_github(\"coolbutuseless/ggthreed\")\n```\n\n\n# Red/blue anaglyphs with `stat_anaglyph()`\n\n**Grab your glasses and lower your expectations!!**\n\n![](man/figures/glasses.jpg)\n\n\n## Usage\n\n* Works with point, line and polygon geoms.  Although \"works\" may be a strong term - \n   the 3d effect is very weak even if you tweak all the parameters\n* It might work with other geoms, but no guarantees that it produces anything \nworth looking at.\n* parameters:\n    * `zoffset`, `zscale` - for determining how `z` aesthetic influences position\n    * `red`, `blue` - hex colours to use for red/blue\n    * `switch` - switch position of the colours\n\n## Example red/blue anaglyphs with points.\n\n\n```{r}\nggplot(mtcars) +\n  geom_point(aes(mpg, y = wt, z = disp), stat = 'anaglyph', alpha = 0.5, zscale = 10) +\n  theme_bw()\n```\n\n\n### Example of combined 3d projection and anaglyph\n\n```{r gallery-cube}\nlibrary(threed)\n\ncamera_to_world \u003c- look_at_matrix(eye = c(1.5, 1.75, 3), at = c(0, 0, 0))\n\nobj \u003c- threed::mesh3dobj$cube %\u003e%\n  transform_by(invert_matrix(camera_to_world)) %\u003e%\n  translate_by(c(0, 0, -3)) %\u003e%\n  perspective_projection()\n\nggplot(obj, aes(x, y, z = z, group = element_id)) +\n  geom_polygon(fill = NA, colour='black', aes(size = hidden), stat = 'anaglyph',\n               zscale = 0.05, zoffset = -1.4, zinvert = FALSE) +\n  scale_linetype_manual(values = c('TRUE' = \"FF\", 'FALSE' = 'solid')) +\n  scale_size_manual(values = c('TRUE' = 0.1, 'FALSE' = 0.5)) +\n  theme_void() +\n  theme(legend.position = 'none') +\n  coord_equal()\n```\n\n\n## Animated Anaglyph\n\n### Animated Icosahedron\n\nSee `vignette('animated-anaglyph', package='ggthreed')`\n\n![](vignettes/gif/animated-anaglyph.gif)\n\n\n# 3d pie charts with `geom_threedpie()`\n\n## Usage\n\n* Requires only an `x` variable - which must be discrete.\n* Default stat is `count`\n* Adjustable parameters:\n    * camera position\n    * pie height\n    * starting angle for first pie slice\n    * tilt angle of pie relative to camera\n\n\n## Issues/Limitations\n\n* `geom_threedpie()` overrides the aspect ratio of the plot it is displaying. \n  This is a gigantic hack!  It means it is not possible to use `coord_fixed()` etc \n  to change the plot aspec ratio.\n* The initial panel grid and x- and y-axes are still generated by the geom. Currently\n  the only way to turn this off it to use `theme_void()`. Not sure how to disable\n  this from within the `geom`.\n* Pie slice resolution is in increments of 2 degrees.\n\n\n## Example - Simple Pie Chart\n\n```{r example-simple, out.width=500, fig.width = 6, fig.height = 4}\nggplot(mtcars) + \n  geom_threedpie(aes(x = as.factor(cyl))) + \n  theme_void() + \n  theme(legend.position = 'bottom')\n```\n\n\n## Example - Facetted Pie Chart\n```{r example-facet}\nggplot(diamonds)  +\n  geom_threedpie(aes(as.factor(cut))) +\n  facet_wrap(~clarity, labeller = label_both) +\n  labs(title = \"Distribution of Diamond Cuts by Clarity\") +\n  scale_fill_brewer(name = \"Cut\", palette = 'Set2') +\n  theme_void()\n```\n\n\n## Example - Behind the Scenes\n\n* This plot shows the polygons making up the pie.\n* Triangular polygons are rendered on top, and quadrilaterals are \n  rendered for the side.\n* The `threed` library is used to rotate the assembled polygons and perform\n  perspective projection.\n* By plotting the polygons in order of distance from the camera (furtherest polygons first), \n  polygons which are behind others are hidden from view.\n* The pie has no bottom.\n* The quadrilaterals making up the side are the same colour as the top, but darkened by 15%.\n\n```{r example-behind}\nggplot(mtcars) + \n  geom_threedpie(aes(x = as.factor(cyl)), alpha = 0.5) + \n  theme_void() + \n  theme(legend.position = 'bottom')\n```\n\n\n## Example - Pie configuration\n\nUser adjustable:\n\n* pie height\n* pie tilt\n* start of first pie slice\n\n\n\n```{r example-animation, eval = FALSE, echo = FALSE}\nN \u003c- 20\nstart_degrees \u003c- seq(  0, 90 , length.out = N)\ntilt_degrees  \u003c- seq(  -20, 50 , length.out = N)\nheights       \u003c- seq(0.1, 0.1, length.out = N)\n\nstart_degrees \u003c- c(start_degrees, rev(start_degrees))\ntilt_degrees  \u003c- c(tilt_degrees , rev(tilt_degrees ))\nheights       \u003c- c(heights      , rev(heights      ))\n\nfor (i in seq_along(start_degrees)) {\n  \n  p \u003c- ggplot(mtcars) + \n    geom_threedpie(aes(x = as.factor(cyl)), start_degrees = start_degrees[i],\n                   tilt_degrees = tilt_degrees[i], height = heights[i]) + \n    theme_void() + \n    theme(legend.position = 'bottom')\n\n  filename \u003c- sprintf(\"%03i.png\", i)\n  print(filename)\n  ggsave(filename, plot=p, width=6, height=4)\n    \n}\n```\n\n![](man/figures/pie-anim.gif)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoolbutuseless%2Fggthreed","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoolbutuseless%2Fggthreed","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoolbutuseless%2Fggthreed/lists"}