-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
160 lines (122 loc) · 3.81 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
---
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.