Order color based on Hue, Saturation, Value in R

﹥>﹥吖頭↗ 提交于 2020-01-30 08:16:06

问题


This question is combination of R and color-theory

I am trying to order color based on Hue (h), then Saturation (s), and finally Value (v)

Here are the painted colors and dataframe from code at end of this post

Painted

Dataframe

       [,1]      [,2]      [,3]      [,4]      [,5]
h 0.6229508 0.2767296 0.1323283 0.9790476 0.9093567
s 0.6421053 0.5145631 0.7928287 0.9510870 0.5480769
v 0.3725490 0.8078431 0.9843137 0.7215686 0.4078431

Do I find the color with lowest h value, keep that as 1st position, out of remaining 4 colors, then find the color with lowest hue, and so forth.

Then how would one sort by saturation, then value.

Note, I'm not asking for code, but rather the logic for doing this.

Any guidance is appreciated.

Code

library(RanglaPunjab)

# Paint the colors
PaintPalette("Teej")

# Store the hex values
mycolors <- RanglaPunjab("Teej")

# Print hex values
mycolors

# Convert Hex to RGB
RGBcol <- col2rgb(mycolors)

# Print RGB values
RGBcol

# Convert RGB to HSV
HSVcol <- rgb2hsv(RGBcol)

# Print dataframe
HSVcol

来源:https://stackoverflow.com/questions/51045459/order-color-based-on-hue-saturation-value-in-r

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!