docs: add rendered logo examples to README gallery
R-CMD-check / R CMD check (push) Successful in 3m38s
R-CMD-check / R CMD check (push) Successful in 3m38s
Show three logo use cases: wordmark on a light plot, compact mark on a dark plot, and multi-plot layout with a shared logo via add_logo_ga().
This commit is contained in:
+55
-7
@@ -187,15 +187,63 @@ ggplot(mpg, aes(displ, hwy)) +
|
|||||||
|
|
||||||
Add the Civilytics logo to any ggplot using the pipe-friendly
|
Add the Civilytics logo to any ggplot using the pipe-friendly
|
||||||
`civilytics_logo()` or the lower-level `add_logo()` / `make_logo_grob()`.
|
`civilytics_logo()` or the lower-level `add_logo()` / `make_logo_grob()`.
|
||||||
|
The logo is automatically right-aligned below the plot area. Wrap the
|
||||||
|
ggplot chain in parentheses before piping --- R's `|>` binds tighter
|
||||||
|
than `+`.
|
||||||
|
|
||||||
```r
|
### Wordmark on a light plot
|
||||||
library(civilytics)
|
|
||||||
library(ggplot2)
|
|
||||||
|
|
||||||
(ggplot(mpg, aes(displ, hwy)) +
|
```{r logo-wordmark, fig.height = 4.5, fig.width = 7}
|
||||||
geom_point() +
|
p <- ggplot(mpg, aes(displ, hwy, colour = class)) +
|
||||||
theme_civilytics()) |>
|
geom_point(size = 2) +
|
||||||
civilytics_logo()
|
scale_color_civilytics() +
|
||||||
|
labs(
|
||||||
|
title = "Fuel economy by engine displacement",
|
||||||
|
caption = "Source: EPA fuel economy data (ggplot2::mpg)",
|
||||||
|
x = "Displacement (L)", y = "Highway MPG"
|
||||||
|
) +
|
||||||
|
theme_civilytics()
|
||||||
|
|
||||||
|
grid::grid.draw(civilytics_logo(p))
|
||||||
|
```
|
||||||
|
|
||||||
|
### Mark on a dark plot
|
||||||
|
|
||||||
|
Use `type = "mark"` for the compact icon and `variant = "dark"` to
|
||||||
|
match a dark background.
|
||||||
|
|
||||||
|
```{r logo-dark, fig.height = 4.5, fig.width = 7}
|
||||||
|
p_dark <- ggplot(mpg, aes(displ, hwy, colour = factor(cyl))) +
|
||||||
|
geom_point(size = 2) +
|
||||||
|
scale_color_civilytics() +
|
||||||
|
labs(
|
||||||
|
title = "Engine size vs. highway fuel economy",
|
||||||
|
colour = "Cylinders",
|
||||||
|
x = "Displacement (L)", y = "Highway MPG"
|
||||||
|
) +
|
||||||
|
theme_civilytics_dark()
|
||||||
|
|
||||||
|
grid::grid.draw(civilytics_logo(p_dark, type = "mark", variant = "dark"))
|
||||||
|
```
|
||||||
|
|
||||||
|
### Multi-plot layout with logo
|
||||||
|
|
||||||
|
Use `add_logo_ga()` to attach a single logo below a row of plots.
|
||||||
|
|
||||||
|
```{r logo-multi, fig.height = 4.5, fig.width = 9}
|
||||||
|
p1 <- ggplot(mpg, aes(class, fill = class)) +
|
||||||
|
geom_bar(show.legend = FALSE) +
|
||||||
|
scale_fill_civilytics() +
|
||||||
|
labs(title = "Vehicle counts", x = NULL, y = NULL) +
|
||||||
|
theme_civilytics(grid = "y")
|
||||||
|
|
||||||
|
p2 <- ggplot(mpg, aes(displ, hwy)) +
|
||||||
|
geom_point(colour = civilytics_colors["navy_600"], size = 1.5) +
|
||||||
|
labs(title = "Displacement vs. MPG", x = "Displacement (L)", y = "Highway MPG") +
|
||||||
|
theme_civilytics(grid = "y")
|
||||||
|
|
||||||
|
logo <- make_logo_grob()
|
||||||
|
grid::grid.draw(add_logo_ga(list(p1, p2), logo))
|
||||||
```
|
```
|
||||||
|
|
||||||
## Other utilities
|
## Other utilities
|
||||||
|
|||||||
@@ -154,18 +154,71 @@ ggplot(mpg, aes(displ, hwy)) +
|
|||||||
|
|
||||||
Add the Civilytics logo to any ggplot using the pipe-friendly
|
Add the Civilytics logo to any ggplot using the pipe-friendly
|
||||||
`civilytics_logo()` or the lower-level `add_logo()` /
|
`civilytics_logo()` or the lower-level `add_logo()` /
|
||||||
`make_logo_grob()`.
|
`make_logo_grob()`. The logo is automatically right-aligned below the
|
||||||
|
plot area. Wrap the ggplot chain in parentheses before piping — R’s `|>`
|
||||||
|
binds tighter than `+`.
|
||||||
|
|
||||||
|
### Wordmark on a light plot
|
||||||
|
|
||||||
``` r
|
``` r
|
||||||
library(civilytics)
|
p <- ggplot(mpg, aes(displ, hwy, colour = class)) +
|
||||||
library(ggplot2)
|
geom_point(size = 2) +
|
||||||
|
scale_color_civilytics() +
|
||||||
|
labs(
|
||||||
|
title = "Fuel economy by engine displacement",
|
||||||
|
caption = "Source: EPA fuel economy data (ggplot2::mpg)",
|
||||||
|
x = "Displacement (L)", y = "Highway MPG"
|
||||||
|
) +
|
||||||
|
theme_civilytics()
|
||||||
|
|
||||||
(ggplot(mpg, aes(displ, hwy)) +
|
grid::grid.draw(civilytics_logo(p))
|
||||||
geom_point() +
|
|
||||||
theme_civilytics()) |>
|
|
||||||
civilytics_logo()
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
<img src="man/figures/README-logo-wordmark-1.png" alt="" width="100%" />
|
||||||
|
|
||||||
|
### Mark on a dark plot
|
||||||
|
|
||||||
|
Use `type = "mark"` for the compact icon and `variant = "dark"` to match
|
||||||
|
a dark background.
|
||||||
|
|
||||||
|
``` r
|
||||||
|
p_dark <- ggplot(mpg, aes(displ, hwy, colour = factor(cyl))) +
|
||||||
|
geom_point(size = 2) +
|
||||||
|
scale_color_civilytics() +
|
||||||
|
labs(
|
||||||
|
title = "Engine size vs. highway fuel economy",
|
||||||
|
colour = "Cylinders",
|
||||||
|
x = "Displacement (L)", y = "Highway MPG"
|
||||||
|
) +
|
||||||
|
theme_civilytics_dark()
|
||||||
|
|
||||||
|
grid::grid.draw(civilytics_logo(p_dark, type = "mark", variant = "dark"))
|
||||||
|
```
|
||||||
|
|
||||||
|
<img src="man/figures/README-logo-dark-1.png" alt="" width="100%" />
|
||||||
|
|
||||||
|
### Multi-plot layout with logo
|
||||||
|
|
||||||
|
Use `add_logo_ga()` to attach a single logo below a row of plots.
|
||||||
|
|
||||||
|
``` r
|
||||||
|
p1 <- ggplot(mpg, aes(class, fill = class)) +
|
||||||
|
geom_bar(show.legend = FALSE) +
|
||||||
|
scale_fill_civilytics() +
|
||||||
|
labs(title = "Vehicle counts", x = NULL, y = NULL) +
|
||||||
|
theme_civilytics(grid = "y")
|
||||||
|
|
||||||
|
p2 <- ggplot(mpg, aes(displ, hwy)) +
|
||||||
|
geom_point(colour = civilytics_colors["navy_600"], size = 1.5) +
|
||||||
|
labs(title = "Displacement vs. MPG", x = "Displacement (L)", y = "Highway MPG") +
|
||||||
|
theme_civilytics(grid = "y")
|
||||||
|
|
||||||
|
logo <- make_logo_grob()
|
||||||
|
grid::grid.draw(add_logo_ga(list(p1, p2), logo))
|
||||||
|
```
|
||||||
|
|
||||||
|
<img src="man/figures/README-logo-multi-1.png" alt="" width="100%" />
|
||||||
|
|
||||||
## Other utilities
|
## Other utilities
|
||||||
|
|
||||||
The package also includes helpers for public-sector data analysis:
|
The package also includes helpers for public-sector data analysis:
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 124 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 155 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 164 KiB |
Reference in New Issue
Block a user