grantmcdermott / grantmcdermott/tinyplot
Colour recycling without `by` variable
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)
- In base R just setting
col = 1:5is sufficient for getting five points in five different colors. - In tinyplot this is identified as a scenaria with only a single
bygroup and hence only one color is used. - This can only be changed easily with a categorical
byvariable.
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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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