Skip to content

Manual palette colours#325

Merged
grantmcdermott merged 5 commits intomainfrom
palette_cols
Feb 25, 2025
Merged

Manual palette colours#325
grantmcdermott merged 5 commits intomainfrom
palette_cols

Conversation

@grantmcdermott
Copy link
Copy Markdown
Owner

Fixes #324

library(tinyplot)
pkgload::load_all("~/Documents/Projects/tinyplot/")
#> ℹ Loading tinyplot
library(palmerpenguins)

tinytheme("clean2", palette.qualitative = c("darkorange", "purple", "cyan4"))

plt(
  bill_depth_mm ~ bill_length_mm | species, penguins,
  pch = "by",
  alpha = 0.8
)

tinytheme("clean2")
plt(
  bill_depth_mm ~ bill_length_mm | species, penguins,
  pch = "by",
  alpha = 0.8,
  palette = c("darkorange", "purple", "cyan4")
)

Colors are recycled with a warning if too few are provided.

plt(
  bill_depth_mm ~ bill_length_mm | species, penguins,
  pch = "by",
  alpha = 0.8,
  palette = c("darkorange", "purple")
)
#> Warning in by_col(ngrps = ngrps, col = col, palette = palette, gradient = by_continuous, : 
#> Fewer colours (2) provided than than there are groups (3). Recycling to make up the shortfall.

Gradient colors are interpolated.

plt(
  bill_depth_mm ~ bill_length_mm | body_mass_g, penguins,
  pch = "by",
  alpha = 0.8,
  palette = c("darkcyan", "white", "purple")
)

Created on 2025-02-24 with reprex v2.1.1

@grantmcdermott grantmcdermott merged commit 1ba0b03 into main Feb 25, 2025
@grantmcdermott grantmcdermott deleted the palette_cols branch February 28, 2025 04:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pass manual colors to palette

1 participant