grantmcdermott / grantmcdermott/tinyplot

Customize lighter colors for area-based displays

Open
#659 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
R
Stars
427
Forks
25
Avg merge
22h 54m
Merged PRs (30d)
28

Description

Follow-up to #657 and #646

To support specifications like lighten = 0.5 in addition to just lighten = TRUE we could use:

lighten_col = function(x, amount = 0.8) {
  x = to_hcl(x)
  hcl(
    h = x[, "H"],
    c = x[, "C"] * (1 - amount),
    l = 100 - (100 - x[, "L"]) * (1 - amount),
    alpha = attr(x, "alpha")
  )
}

By default this yields similar colors as the current lighten_fill() which is based on seq_palette(..., n = 3)[3]. Because we just need the lightened color here (rather than a palette going from the full color to the lightened one), lighten_col() can be a little bit simpler and hence leads to slightly different output.

Additionally, we may want to build in a catch that makes sure that lighten_col("black") returns "lightgray" to be exactly consistent with base R.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading follow-up issues #657 and #646, then find the existing lighten_fill() implementation and the area-based display code it serves. Support numeric lighten values such as 0.5 while preserving TRUE behavior, and verify whether black should produce lightgray for consistency with base R.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data-visualization
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
62/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.