Home

Awesome

Project Status: Active – The project has reached a stable, usable
state and is being actively
developed. Signed
by Signed commit
% R-CMD-check Minimal R
Version License

ggsolar

Generate Solar System Plots

Description

Generate “solar system” plots using everyone’s favorite plotting package.

What’s Inside The Tin

The following functions are implemented:

Installation

remotes::install_github("hrbrmstr/ggsolar")

NOTE: To use the ‘remotes’ install options you will need to have the {remotes} package installed.

Usage

library(ggsolar)
library(ggplot2)

# current version
packageVersion("ggsolar")
## [1] '0.1.1'

Sol

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()
<img src="man/figures/README-sol-1.png" width="576" />

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):

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()
<img src="man/figures/README-sol-sqrt-1.png" width="672" />

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):

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()
<img src="man/figures/README-sol-precise-sqrt-1.png" width="672" />

Rando!

set.seed(42)
(rando_planets <- generate_random_planets(12))
##  [1] "Ososi"       "Morlambtune" "Obli VI"     "Lantitan"    "Tanthos"     "Onhy"        "Lesbomor C"  "Radido"     
##  [9] "Lesstel"     "Altan prime" "Lasdre"      "Brenta"

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()
<img src="man/figures/README-rando-1.png" width="576" />

ggsolar Metrics

Lang# Files(%)LoC(%)Blank lines(%)# Lines(%)
R80.362150.32470.251540.39
Rmd10.05800.12380.20420.11
YAML20.09380.06100.0520.01
SUM110.503330.50950.501980.50

clock Package Metrics for ggsolar

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.