Skip to content

Colour recycling without by variable #483

@zeileis

Description

@zeileis

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions