Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hrbrmstr/ggsolar
🪐 Generate "solar system" plots with {ggplot2}
https://github.com/hrbrmstr/ggsolar
ggplot2 r rstats
Last synced: 10 days ago
JSON representation
🪐 Generate "solar system" plots with {ggplot2}
- Host: GitHub
- URL: https://github.com/hrbrmstr/ggsolar
- Owner: hrbrmstr
- License: other
- Created: 2023-04-12T05:47:15.000Z (over 1 year ago)
- Default Branch: batman
- Last Pushed: 2023-04-26T07:31:28.000Z (over 1 year ago)
- Last Synced: 2024-10-12T21:24:03.381Z (26 days ago)
- Topics: ggplot2, r, rstats
- Language: R
- Homepage: https://rud.is/b/2023/04/12/make-solar-system-plots-with-ggsolar/
- Size: 501 KB
- Stars: 24
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
Awesome Lists containing this project
README
---
output: rmarkdown::github_document
editor_options:
chunk_output_type: console
---
```{r pkg-knitr-opts, include=FALSE}
hrbrpkghelpr::global_opts()
``````{r badges, results='asis', echo=FALSE, cache=FALSE}
hrbrpkghelpr::stinking_badges()
``````{r description, results='asis', echo=FALSE, cache=FALSE}
hrbrpkghelpr::yank_title_and_description()
```## What's Inside The Tin
The following functions are implemented:
```{r ingredients, results='asis', echo=FALSE, cache=FALSE}
hrbrpkghelpr::describe_ingredients()
```## Installation
```{r install-ex, results='asis', echo=FALSE, cache=FALSE}
hrbrpkghelpr::install_block()
```## Usage
```{r lib-ex}
library(ggsolar)
library(ggplot2)# current version
packageVersion("ggsolar")```
## Sol
```{r sol, fig.width=6, fig.height=6, dev.args=list(bg="transparent")}
sol_orbits <- generate_orbits(sol_planets)set.seed(1323) # this produced decent placements
placed_planets <- randomize_planet_positions(sol_orbits)
plot_orbits(
orbits = sol_orbits,
planet_positions = placed_planets,
label_planets = TRUE,
label_family = hrbrthemes::font_es_bold
) +
hrbrthemes::theme_ipsum_es(grid="") +
coord_equal() +
labs(
title = "Sol",
caption = "Pluto is 100% a planet"
) +
theme_enhance_solar()
```## Non-uniform Radii
We'll plot Sol's system with the square root of the actual radius AU's (which are `0.39`, `0.72`, `1.00`, `1.52`, `5.20`, `9.58`, `19.18`, `30.07`, `39.48`):
```{r sol-sqrt, fig.width=7, fig.height=7, dev.args=list(bg="transparent")}
sol_dist <- sqrt(c(0.39, 0.72, 1.00, 1.52, 5.20, 9.58, 19.18, 30.07, 39.48))
sol_orbits <- generate_orbits(sol_planets, radii = sol_dist, num_polygon_points = 1000)set.seed(42)
sol_placements <- randomize_planet_positions(sol_orbits)plot_orbits(
orbits = sol_orbits,
planet_positions = sol_placements,
label_planets = TRUE,
label_family = hrbrthemes::font_es_bold
) +
hrbrthemes::theme_ipsum_es(grid="") +
coord_equal() +
labs(
title = "Sol System (Orbits AU Sqrt.)",
subtitle = "Non-uniform Radii",
caption = "Pluto is 100% a planet"
) +
theme_enhance_solar()
```## Custom Planet Placements!
We'll plot Sol's system with the square root of the actual radius AU's (which are `0.39`, `0.72`, `1.00`, `1.52`, `5.20`, `9.58`, `19.18`, `30.07`, `39.48`):
```{r sol-precise-sqrt, fig.width=7, fig.height=7, dev.args=list(bg="transparent")}
sol_dist <- sqrt(c(0.39, 0.72, 1.00, 1.52, 5.20, 9.58, 19.18, 30.07, 39.48))
sol_orbits <- generate_orbits(sol_planets, radii = sol_dist, num_polygon_points = 1000)my_pos <- function(n) {
seq(from = 0, to = 1, length.out = 9)
}sol_placements <- randomize_planet_positions(sol_orbits, randomizer = my_pos)
plot_orbits(
orbits = sol_orbits,
planet_positions = sol_placements,
label_planets = TRUE,
label_family = hrbrthemes::font_es_bold
) +
hrbrthemes::theme_ipsum_es(grid="") +
coord_equal() +
labs(
title = "Sol System (Orbits AU Sqrt.)",
subtitle = "Custom placements",
caption = "Pluto is 100% a planet"
) +
theme_enhance_solar()
```## Rando!
```{r rando, fig.width=6, fig.height=6, dev.args=list(bg="transparent")}
set.seed(42)
(rando_planets <- generate_random_planets(12))rando_orbits <- generate_orbits(rando_planets)
set.seed(123) # this produced decent placements
placed_planets <- randomize_planet_positions(rando_orbits)
plot_orbits(
orbits = rando_orbits,
planet_positions = placed_planets,
label_planets = TRUE,
label_family = hrbrthemes::font_es_bold
) +
hrbrthemes::theme_ipsum_es(grid="") +
coord_equal() +
labs(
title = "Rando System"
) +
theme_enhance_solar()
```## ggsolar Metrics
```{r cloc, echo=FALSE}
cloc::cloc_pkg_md()
```## Code of Conduct
Please note that this project is released with a Contributor Code of Conduct.
By participating in this project you agree to abide by its terms.