- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to get the colour name from colour code in R?
To get the color name from color code, we can use the color_id function of plotrix package. If we have a vector of colour codes say x then the colour name can be found by using the command sapply(x,color.id).
Example
> x<-c("#FF0000","#FF1F00","#FF3D00","#FF5C00","#FF7A00","#FF9900","#FFB800","#FFD600","#FFF500","#EBFF00","#CCFF00","#ADFF00","#8FFF00","#70FF00","#52FF00","#33FF00","#14FF00","#00FF0A","#00FF29","#00FF47","#00FF66","#00FF85","#00FFA3","#00FFC2","#00FFE0","#00FFFF","#00E0FF","#00C2FF","#00A3FF","#0085FF","#0066FF","#0047FF","#0029FF","#000AFF","#1400FF","#3300FF","#5200FF","#7000FF","#8F00FF","#AD00FF","#CC00FF","#EB00FF","#FF00F5","#FF00D6","#FF00B8","#FF0099","#FF007A","#FF005C","#FF003D","#FF001F") > x
Output
[1] "#FF0000" "#FF1F00" "#FF3D00" "#FF5C00" "#FF7A00" "#FF9900" "#FFB800" [8] "#FFD600" "#FFF500" "#EBFF00" "#CCFF00" "#ADFF00" "#8FFF00" "#70FF00" [15] "#52FF00" "#33FF00" "#14FF00" "#00FF0A" "#00FF29" "#00FF47" "#00FF66" [22] "#00FF85" "#00FFA3" "#00FFC2" "#00FFE0" "#00FFFF" "#00E0FF" "#00C2FF" [29] "#00A3FF" "#0085FF" "#0066FF" "#0047FF" "#0029FF" "#000AFF" "#1400FF" [36] "#3300FF" "#5200FF" "#7000FF" "#8F00FF" "#AD00FF" "#CC00FF" "#EB00FF" [43] "#FF00F5" "#FF00D6" "#FF00B8" "#FF0099" "#FF007A" "#FF005C" "#FF003D" [50] "#FF001F"
Loading plotrix package and finding the colour names for the colour codes in x −
> library(plotrix) > sapply(x,color.id)
Output
$`#FF0000` [1] "red" "red1" $`#FF1F00` [1] "red" "red1" $`#FF3D00` [1] "orangered" "orangered1" $`#FF5C00` [1] "orangered" "orangered1" $`#FF7A00` [1] "darkorange1" $`#FF9900` [1] "orange" "orange1" $`#FFB800` [1] "darkgoldenrod1" $`#FFD600` [1] "gold" "gold1" $`#FFF500` [1] "yellow" "yellow1" $`#EBFF00` [1] "yellow2" $`#CCFF00` [1] "yellow2" $`#ADFF00` [1] "chartreuse" "chartreuse1" $`#8FFF00` [1] "chartreuse" "chartreuse1" $`#70FF00` [1] "lawngreen" $`#52FF00` [1] "chartreuse2" $`#33FF00` [1] "green" "green1" $`#14FF00` [1] "green" "green1" $`#00FF0A` [1] "green" "green1" $`#00FF29` [1] "green" "green1" $`#00FF47` [1] "springgreen2" $`#00FF66` [1] "springgreen2" $`#00FF85` [1] "springgreen" "springgreen1" $`#00FFA3` [1] "mediumspringgreen" $`#00FFC2` [1] "mediumspringgreen" $`#00FFE0` [1] "cyan2" $`#00FFFF` [1] "cyan" "cyan1" $`#00E0FF` [1] "turquoise2" $`#00C2FF` [1] "deepskyblue" "deepskyblue1" $`#00A3FF` [1] "deepskyblue2" $`#0085FF` [1] "dodgerblue" "dodgerblue1" $`#0066FF` [1] "dodgerblue2" $`#0047FF` [1] "blue" "blue1" $`#0029FF` [1] "blue" "blue1" $`#000AFF` [1] "blue" "blue1" $`#1400FF` [1] "blue" "blue1" $`#3300FF` [1] "blue" "blue1" $`#5200FF` [1] "purple3" $`#7000FF` [1] "darkviolet" $`#8F00FF` [1] "purple" $`#AD00FF` [1] "purple" $`#CC00FF` [1] "magenta2" $`#EB00FF` [1] "magenta2" $`#FF00F5` [1] "magenta" "magenta1" $`#FF00D6` [1] "magenta2" $`#FF00B8` [1] "deeppink" "deeppink1" $`#FF0099` [1] "deeppink" "deeppink1" $`#FF007A` [1] "deeppink2" $`#FF005C` [1] "deeppink2" $`#FF003D` [1] "firebrick1" $`#FF001F` [1] "red" "red1"$`#FF0000` [1] "red" "red1" $`#FF1F00` [1] "red" "red1" $`#FF3D00` [1] "orangered" "orangered1" $`#FF5C00` [1] "orangered" "orangered1" $`#FF7A00` [1] "darkorange1" $`#FF9900` [1] "orange" "orange1" $`#FFB800` [1] "darkgoldenrod1" $`#FFD600` [1] "gold" "gold1" $`#FFF500` [1] "yellow" "yellow1" $`#EBFF00` [1] "yellow2" $`#CCFF00` [1] "yellow2" $`#ADFF00` [1] "chartreuse" "chartreuse1" $`#8FFF00` [1] "chartreuse" "chartreuse1" $`#70FF00` [1] "lawngreen" $`#52FF00` [1] "chartreuse2" $`#33FF00` [1] "green" "green1" $`#14FF00` [1] "green" "green1" $`#00FF0A` [1] "green" "green1" $`#00FF29` [1] "green" "green1" $`#00FF47` [1] "springgreen2" $`#00FF66` [1] "springgreen2" $`#00FF85` [1] "springgreen" "springgreen1" $`#00FFA3` [1] "mediumspringgreen" $`#00FFC2` [1] "mediumspringgreen" $`#00FFE0` [1] "cyan2" $`#00FFFF` [1] "cyan" "cyan1" $`#00E0FF` [1] "turquoise2" $`#00C2FF` [1] "deepskyblue" "deepskyblue1" $`#00A3FF` [1] "deepskyblue2" $`#0085FF` [1] "dodgerblue" "dodgerblue1" $`#0066FF` [1] "dodgerblue2" $`#0047FF` [1] "blue" "blue1" $`#0029FF` [1] "blue" "blue1" $`#000AFF` [1] "blue" "blue1" $`#1400FF` [1] "blue" "blue1" $`#3300FF` [1] "blue" "blue1" $`#5200FF` [1] "purple3" $`#7000FF` [1] "darkviolet" $`#8F00FF` [1] "purple" $`#AD00FF` [1] "purple" $`#CC00FF` [1] "magenta2" $`#EB00FF` [1] "magenta2" $`#FF00F5` [1] "magenta" "magenta1" $`#FF00D6` [1] "magenta2" $`#FF00B8` [1] "deeppink" "deeppink1" $`#FF0099` [1] "deeppink" "deeppink1" $`#FF007A` [1] "deeppink2" $`#FF005C` [1] "deeppink2" $`#FF003D` [1] "firebrick1" $`#FF001F` [1] "red" "red1"
- Related Articles
- How to get the default blue colour of matplotlib.pyplot.scatter?
- How to change the abline colour created using ggplot2 in R?
- Colour Theory and Colour Psychology
- How to get the data type name from the java.sql.Type code using JDBC?
- How do plants are green in colour and water blue in colour?
- How to get the current colour of the character at cursor in IText using FabricJS?
- How to use column with colours to change the colour of points using ggplot2 in R?
- How to get the code name and product name of the browser in JavaScript?
- Colour Spectrum
- How to change notification background colour in Android?
- Converting an image from colour to grayscale using OpenCV
- How to set the background colour of Line in FabricJS?
- How to set the border colour of Image in FabricJS?
- How to Automatically Colour the Alternating Rows/Columns in Excel?
- Colour Palette in Design

Advertisements