Skip to content

Commit

Permalink
Fix coord_geo_radial usage
Browse files Browse the repository at this point in the history
  • Loading branch information
willgearty committed Apr 23, 2024
1 parent 9176c91 commit 1b60141
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 22 deletions.
30 changes: 19 additions & 11 deletions vignettes/b-advanced-ggplot.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -355,10 +355,16 @@ library(deeptime)
revts(ggtree(vertebrate.tree, size = 1)) +
scale_x_continuous(breaks = seq(-500, 0, 100),
labels = seq(500, 0, -100),
limits = c(-500, 0)) +
coord_geo_polar(dat = "periods") +
theme(line = element_line(linewidth = 1),
axis.text.r = element_text(size = 5, hjust = -0.5, vjust = -1.5))
limits = c(-500, 0),
expand = expansion(mult = 0)) +
scale_y_continuous(guide = NULL) +
coord_geo_radial(dat = "periods") +
theme_classic()
```

```
## Scale for y is already present.
## Adding another scale for y, which will replace the existing scale.
```

<div class="figure">
Expand All @@ -374,10 +380,11 @@ revts(ggtree(vertebrate.tree, size = 1)) %<+% vertebrate_data +
geom_phylopic(aes(img = svg), size = 25) +
scale_x_continuous(breaks = seq(-500, 0, 100),
labels = seq(500, 0, -100),
limits = c(-500, 0)) +
coord_geo_polar(dat = "periods") +
theme(line = element_line(linewidth = 1),
axis.text.r = element_text(size = 5, hjust = -0.5, vjust = -1.5))
limits = c(-500, 0),
expand = expansion(mult = 0)) +
scale_y_continuous(guide = NULL) +
coord_geo_radial(dat = "periods") +
theme_classic()
```

<div class="figure">
Expand All @@ -401,10 +408,11 @@ revts(ggtree(vertebrate.tree, size = 1)) %<+% vertebrate_data +
geom_phylopic(aes(img = svg), size = 25) +
scale_x_continuous(breaks = seq(-500, 0, 100),
labels = seq(500, 0, -100),
limits = c(-500, 0)) +
limits = c(-500, 0),
expand = expansion(mult = 0)) +
scale_y_continuous(guide = NULL) +
coord_geo_radial(dat = "periods") +
theme(line = element_line(linewidth = 1),
axis.text.r = element_text(size = 5, hjust = -0.5, vjust = -1.5))
theme_classic()
```

<div class="figure">
Expand Down
25 changes: 14 additions & 11 deletions vignettes/b-advanced-ggplot.Rmd.orig
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,11 @@ library(deeptime)
revts(ggtree(vertebrate.tree, size = 1)) +
scale_x_continuous(breaks = seq(-500, 0, 100),
labels = seq(500, 0, -100),
limits = c(-500, 0)) +
coord_geo_polar(dat = "periods") +
theme(line = element_line(linewidth = 1),
axis.text.r = element_text(size = 5, hjust = -0.5, vjust = -1.5))
limits = c(-500, 0),
expand = expansion(mult = 0)) +
scale_y_continuous(guide = NULL) +
coord_geo_radial(dat = "periods") +
theme_classic()
```

That's looking a lot prettier! Let's go ahead and add our silhouettes now. Note that we need to attach the `vertebrate_data` object with the `%<+%` operator from `{ggtree}`.
Expand All @@ -291,10 +292,11 @@ revts(ggtree(vertebrate.tree, size = 1)) %<+% vertebrate_data +
geom_phylopic(aes(img = svg), size = 25) +
scale_x_continuous(breaks = seq(-500, 0, 100),
labels = seq(500, 0, -100),
limits = c(-500, 0)) +
coord_geo_polar(dat = "periods") +
theme(line = element_line(linewidth = 1),
axis.text.r = element_text(size = 5, hjust = -0.5, vjust = -1.5))
limits = c(-500, 0),
expand = expansion(mult = 0)) +
scale_y_continuous(guide = NULL) +
coord_geo_radial(dat = "periods") +
theme_classic()
```

Note that only a single size is specified and aspect ratio is always maintained, hence why the silhouettes all have the same height but different widths. Let's fix some of the silhouettes by rotating them 90 degrees:
Expand All @@ -311,10 +313,11 @@ revts(ggtree(vertebrate.tree, size = 1)) %<+% vertebrate_data +
geom_phylopic(aes(img = svg), size = 25) +
scale_x_continuous(breaks = seq(-500, 0, 100),
labels = seq(500, 0, -100),
limits = c(-500, 0)) +
limits = c(-500, 0),
expand = expansion(mult = 0)) +
scale_y_continuous(guide = NULL) +
coord_geo_radial(dat = "periods") +
theme(line = element_line(linewidth = 1),
axis.text.r = element_text(size = 5, hjust = -0.5, vjust = -1.5))
theme_classic()
```

Beautiful!
Expand Down
Binary file modified vignettes/ggplot-phylo-plot-2-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified vignettes/ggplot-phylo-plot-3-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified vignettes/ggplot-phylo-plot-4-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 1b60141

Please sign in to comment.