Skip to content

Commit cf021be

Browse files
style and docs: run devtools::document() and styler::style_pkg() (#69)
Co-authored-by: sbreitbart-NOAA <181890943+sbreitbart-NOAA@users.noreply.github.com>
1 parent e29096e commit cf021be

File tree

3 files changed

+33
-24
lines changed

3 files changed

+33
-24
lines changed

R/nmfs_cols.R

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -366,22 +366,29 @@ display_nmfs_palette <- function(name, n) {
366366
color = pal
367367
)
368368

369-
ggplot2::ggplot(df,
370-
ggplot2::aes(x = y,
371-
y = x,
372-
fill = color)) +
369+
ggplot2::ggplot(
370+
df,
371+
ggplot2::aes(
372+
x = y,
373+
y = x,
374+
fill = color
375+
)
376+
) +
373377
ggplot2::geom_tile() +
374378
ggplot2::scale_fill_identity() +
375379
ggplot2::coord_fixed(ratio = 1) +
376380
ggplot2::theme_void() +
377381
ggplot2::labs(title = name) +
378-
ggplot2::theme(plot.title = ggplot2::element_text(hjust = 0.5,
379-
vjust = 1,
380-
size = 12,
381-
face = "bold"),
382-
plot.margin = ggplot2::unit(c(1,1,1,1), "cm"))
383-
# plot.margin = ggplot2::unit(c(2,2,2,2), "cm"))
384-
382+
ggplot2::theme(
383+
plot.title = ggplot2::element_text(
384+
hjust = 0.5,
385+
vjust = 1,
386+
size = 12,
387+
face = "bold"
388+
),
389+
plot.margin = ggplot2::unit(c(1, 1, 1, 1), "cm")
390+
)
391+
# plot.margin = ggplot2::unit(c(2,2,2,2), "cm"))
385392
}
386393

387394
#' Return function that shows all nmfs color palettes
@@ -392,20 +399,21 @@ display_nmfs_palette <- function(name, n) {
392399
#' @return A null object showing all nmfs color palettes in the plot window.
393400
#' @export
394401
all_nmfs_palettes <- function() {
395-
396402
# default setting
397-
old_par <- par(mar = c(0,6,0,0))
403+
old_par <- par(mar = c(0, 6, 0, 0))
398404

399405
# reset par to original setting
400406
on.exit(par(old_par))
401407

402-
do.call(
403-
pals::pal.bands,
404-
c(nmfs_palettes,
405-
list(labels = names(nmfs_palettes),
406-
gap = 0.1,
407-
show.names = FALSE)
408-
)
408+
do.call(
409+
pals::pal.bands,
410+
c(
411+
nmfs_palettes,
412+
list(
413+
labels = names(nmfs_palettes),
414+
gap = 0.1,
415+
show.names = FALSE
416+
)
409417
)
410-
418+
)
411419
}

tests/testthat/test-scale-fill.R

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ test_that("scale_fill works with discrete = TRUE and interpolate = FALSE", {
6161
})
6262

6363
test_that("warning triggered if palette is too small to use", {
64-
6564
expect_warning(
6665
ggplot(mpg, aes(x = model, y = displ, color = manufacturer)) +
6766
geom_point() +

tests/testthat/test-snapshot-palettes.R

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ test_that("nmfs_palette() works", {
1818
test_that("nmfs_palette() fails", {
1919
expect_error(nmfs_palette("foo"))
2020

21-
expect_error(nmfs_palette("foo"),
22-
"need at least two non-NA values to interpolate")
21+
expect_error(
22+
nmfs_palette("foo"),
23+
"need at least two non-NA values to interpolate"
24+
)
2325
})
2426

2527
test_that("display_nmfs_palette() works", {

0 commit comments

Comments
 (0)