diff --git a/DESCRIPTION b/DESCRIPTION
index 455efea..b881b72 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -16,7 +16,8 @@ License: GPL (>= 3)
Depends:
R (>= 2.10)
Imports:
- stringr
+ stringr,
+ withr
Suggests:
covr,
sf
diff --git a/NAMESPACE b/NAMESPACE
index b2437f4..bd6db72 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -18,3 +18,4 @@ importFrom(graphics,par)
importFrom(graphics,rect)
importFrom(graphics,text)
importFrom(stringr,str_pad)
+importFrom(withr,with_par)
diff --git a/R/oxfordtheme.R b/R/oxfordtheme.R
index fc2b05d..b242b13 100644
--- a/R/oxfordtheme.R
+++ b/R/oxfordtheme.R
@@ -13,5 +13,6 @@
#' @importFrom stringr str_pad
#' @importFrom grDevices col2rgb rgb colorRampPalette
#' @importFrom graphics rect par image text
+#' @importFrom withr with_par
#'
"_PACKAGE"
diff --git a/R/utils.R b/R/utils.R
index 5e66f5c..5dc0fd8 100644
--- a/R/utils.R
+++ b/R/utils.R
@@ -46,9 +46,14 @@ print.palette <- function(x, ...) {
# old <- par(mar = c(0.5, 0.5, 0.5, 0.5))
# on.exit(par(old))
- image(1:n, 1, as.matrix(1:n), col = x,
- ylab = "", xaxt = "n", yaxt = "n", bty = "n")
+ withr::with_par(
+ new = list(mar = c(0.5, 0.5, 0.5, 0.5)),
+ code = {
+ image(1:n, 1, as.matrix(1:n), col = x,
+ ylab = "", xaxt = "n", yaxt = "n", bty = "n")
- rect(0, 0.9, n + 1, 1.1, col = rgb(1, 1, 1, 0.8), border = NA)
- text((n + 1) / 2, 1, labels = attr(x, "name"), cex = 1, family = "serif")
+ rect(0, 0.9, n + 1, 1.1, col = rgb(1, 1, 1, 0.8), border = NA)
+ text((n + 1) / 2, 1, labels = attr(x, "name"), cex = 1, family = "serif")
+ }
+ )
}
diff --git a/README.Rmd b/README.Rmd
index 6d811ac..c2b472a 100644
--- a/README.Rmd
+++ b/README.Rmd
@@ -61,7 +61,7 @@ oxford_colours |>
knitr::kable()
```
-```{r oxford-colours-graphic, echo = FALSE, fig.height = 1}
+```{r oxford-colours-graphic, echo = FALSE, fig.height = 1, fig.align = "center"}
structure(get_oxford_colours() |> (\(x) x[x != ""])(), class = "palette", name = "Oxford Colours")
```
@@ -87,7 +87,7 @@ Based on the [University of Oxford](https://ox.ac.uk)'s [visual identity guideli
oxford_theme_palettes()$heritage
```
-```{r oxford-palettes-heritage-show, echo = FALSE, fig.height = 1}
+```{r oxford-palettes-heritage-show, echo = FALSE, fig.height = 1, fig.align = "center"}
structure(oxford_theme_palettes()$heritage, class = "palette", name = "heritage")
```
@@ -97,7 +97,7 @@ structure(oxford_theme_palettes()$heritage, class = "palette", name = "heritage"
oxford_theme_palettes()$contemporary
```
-```{r oxford-palettes-contemporary-show, echo = FALSE, fig.height = 1}
+```{r oxford-palettes-contemporary-show, echo = FALSE, fig.height = 1, fig.align = "center"}
structure(oxford_theme_palettes()$contemporary, class = "palette", name = "contemporary")
```
@@ -107,7 +107,7 @@ structure(oxford_theme_palettes()$contemporary, class = "palette", name = "conte
oxford_theme_palettes()$celebratory
```
-```{r oxford-palettes-celebratory-show, echo = FALSE, fig.height = 1}
+```{r oxford-palettes-celebratory-show, echo = FALSE, fig.height = 1, fig.align = "center"}
structure(oxford_theme_palettes()$celebratory, class = "palette", name = "celebratory")
```
@@ -117,7 +117,7 @@ structure(oxford_theme_palettes()$celebratory, class = "palette", name = "celebr
oxford_theme_palettes()$corporate
```
-```{r oxford-palettes-corporate-show, echo = FALSE, fig.height = 1}
+```{r oxford-palettes-corporate-show, echo = FALSE, fig.height = 1, fig.align = "center"}
structure(oxford_theme_palettes()$corporate, class = "palette", name = "corporate")
```
diff --git a/README.md b/README.md
index 797ab5b..4d69a1a 100644
--- a/README.md
+++ b/README.md
@@ -96,7 +96,7 @@ the following colours are available from this package:
| Gold | | | | 10122C |
| Silver | | | | 10103C |
-![](man/figures/README-oxford-colours-graphic-1.png)
+
You can access either the name, RGB, CMYK, hex code, and/or Pantone
values of each Oxford colour through the `get_oxford_colours()` function
@@ -136,7 +136,7 @@ oxford_theme_palettes()$heritage
#> [1] "#994636" "#E08D79" "#C4A29E" "#A0AF84" "#426A5A"
```
-![](man/figures/README-oxford-palettes-heritage-show-1.png)
+
#### Contemporary
@@ -145,7 +145,7 @@ oxford_theme_palettes()$contemporary
#> [1] "#FE615A" "#ED9390" "#E4F0EF" "#789E9E" "#00AAB4"
```
-![](man/figures/README-oxford-palettes-contemporary-show-1.png)
+
#### Celebratory
@@ -154,7 +154,7 @@ oxford_theme_palettes()$celebratory
#> [1] "#15616D" "#776885" "#E2C044" "#D4CDF4" "#7F055F"
```
-![](man/figures/README-oxford-palettes-celebratory-show-1.png)
+
#### Corporate
@@ -163,7 +163,7 @@ oxford_theme_palettes()$corporate
#> [1] "#FB5607" "#B9D6F2" "#95C11F" "#49B6FF" "#1D42A6"
```
-![](man/figures/README-oxford-palettes-corporate-show-1.png)
+
### Oxford theme paletttes for use in plotting