grantmcdermott / grantmcdermott/tinyplot

Colour recycling without `by` variable

Open
#483 2 comments 3 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

In #410 we had improved the colour recycling when groups are defined using a by variable. This still seems to be fine to me.

When there is no by variable, i.e., only y and/or x, then only a single color is used because there is only a single by group. This makes sense in many situations but sometimes you want to color every point/line/bar with a different color (as in #476). This is possible in base R's plot() but in tinyplot() it requires setting up a suitable by variable.

As a simple example, consider plotting points 1:5 in colors 1:5:

    plot(1:5, col = 1:5, pch = 19, cex = 5)
tinyplot(1:5, col = 1:5, pch = 19, cex = 5)
tinyplot(1:5, col = 1:5, pch = 19, cex = 5, by = factor(1:5), legend = FALSE)
Image
  • In base R just setting col = 1:5 is sufficient for getting five points in five different colors.
  • In tinyplot this is identified as a scenaria with only a single by group and hence only one color is used.
  • This can only be changed easily with a categorical by variable.

Maybe in the case without by variable we need to reconsider the color recycling rules?

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 reproducing the three plotting examples in the issue and compare tinyplot with base R when no by variable is supplied. Trace the color-recycling behavior in tinyplot and review related work in issues #410 and #476. Done means the intended no-by color rules are decided, implemented, and covered by regression examples or tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data-visualization
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.