grantmcdermott · GitHub

Fixes #352

## data and package
dd = datasauRus::datasaurus_dozen
pkgload::load_all("~/Documents/Projects/tinyplot/")
#> ℹ Loading tinyplot
## default: partially empty, fallback to sequential (restricted viridis)
plt(y ~ x | dataset, facet = "by", data = dd, pch = 18, legend = FALSE)

## insufficient palette: recycle with warning
plt(y ~ x | dataset, facet = "by", data = dd, pch = 18, legend = FALSE, palette = "Okabe-Ito")
#> Warning in gen_pal_fun(palette, gradient = gradient, alpha = alpha, n = ngrps): 
#> Fewer colours 9 provided than than there are groups 13. Recycling to make up the shortfall.

## sufficient palette: ok
plt(y ~ x | dataset, facet = "by", data = dd, pch = 18, legend = FALSE, palette = "Dark 3")

## default theme with palette.qualitative (insufficient) & palette.sequential: ok (fallover to sequential)
tinytheme()
plt(y ~ x | dataset, facet = "by", data = dd, pch = 18, legend = FALSE)

## theme with palette.qualitative (insufficient) & palette.sequential: ok (fallover to sequential)
tinytheme("minimal")
plt(y ~ x | dataset, facet = "by", data = dd, pch = 18, legend = FALSE)

## theme with palette.qualitative (sufficient by name) & palette.sequential: still failover to sequential
tinytheme("minimal", palette.qualitative = "Dark 3")
plt(y ~ x | dataset, facet = "by", data = dd, pch = 18, legend = FALSE)

## theme with palette.qualitative (sufficient by vector) & palette.sequential: ok
tinytheme("minimal", palette.qualitative = hcl.colors(13, "Dark 3"))
plt(y ~ x | dataset, facet = "by", data = dd, pch = 18, legend = FALSE)
## theme with palette.qualitative (insufficient) & palette.sequential (too short): recycling, with warning
tinytheme("minimal", palette.sequential = hcl.colors(9))
plt(y ~ x | dataset, facet = "by", data = dd, pch = 18, legend = FALSE)
#> Warning in by_col(ngrps = ngrps, col = col, palette = palette, gradient = by_continuous, : 
#> Fewer colours (9) provided than than there are groups (13). Recycling to make up the shortfall.

tinytheme()

Created on 2025-05-21 with reprex v2.1.1

Read the original on github.com ↗