Is there a function that can be used to display a rgb color?
Assuming a rgb color was created like this:
library(grDevices)
test<- rgb(red=100, green=125, blue20, max=225)
How can I check the real color looks like so that can adjust the parameter for red, green and blue?
I'm not familiar with an existing function, but you could create one that plots one point with the created color.
library(grDevices)
show_color = function(i) {
plot(10,
col = i,
pch = 19, cex = 20,
xlab = '', ylab = '',
xaxt = 'n', yaxt = 'n',
bty = 'n')
}
test1 <- rgb(red=100, green=125, blue=20, max=225)
test2 <- rgb(red=105, green=88, blue=30, max=125)
show_color(test1)
show_color(test2)
Created on 2023-04-17 with reprex v2.0.2
Thank you so much!
Great function!
in case you want to compare how well several colours work together or even check multiple palettes of colours the pal.bands function from the pals package is great:
pals::pal.bands(c(rgb(red=100, green=125, blue=20, max=225),
rgb(red=105, green=88, blue=30, max=125)) )
# or define the palette first
test1 = rgb(red=100, green=125, blue=20, max=225)
test2 = rgb(red=105, green=88, blue=30, max=125)
palette = c(test2, test1)
pals::pal.bands(palette)
This is really cool! Thank you!