Skip to content

Instantly share code, notes, and snippets.

@LTLA
Created July 19, 2022 05:12
Show Gist options
  • Save LTLA/d665c748ed091dea2ef4aad5ddb85211 to your computer and use it in GitHub Desktop.
Save LTLA/d665c748ed091dea2ef4aad5ddb85211 to your computer and use it in GitHub Desktop.
Decent HCL random color generation
# The hue is evenly distributed along the circle;
# we oscillate the luminescence to provide a better
# distinction between similar colors.
n <- 30
i <- head(seq(0, 360, length.out=n+1), -1)
cols <- hcl(i, c=50, l=80 + 10 * sin(i/30 * pi))
plot(seq_along(cols), col=cols, pch=16, cex=5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment