How to generate color palettes with colorRamPalette function
This article mainly introduces "how to use colorRamPalette function to generate color palette". In daily operation, I believe that many people have doubts about how to use colorRamPalette function to generate color palette. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubt of "how to use colorRamPalette function to generate color palette". Next, please follow the editor to study!
ColorRamPalette is a grDevices package function that can be used to generate gradient palettes
The return value of the function is still a function, and then enter the corresponding number of swatches to get the corresponding color value, for example, between red and green (rgb), the five colors of the gradient (if the color involved is not only red and green, it is also possible):
> rgb.palette=colorRampPalette (c ("red", "green"), space = "rgb") > rgb.palette (5) [1] "# FF0000", # BF3F00 "# 7F7F00", "# 3FBF00"# 00FF00" > barplot
The result of setting the Lab color by space is as follows:
> Lab.palette = colorRampPalette (c ("red", "green"), space = "Lab") > Lab.palette (5) [1] "# FF0000", "# E77600", "# C8AB00", "# 97D600", "# 00FF00" > barplot (1). This is the end of the study on "how to use the colorRamPalette function to generate a color palette". I hope to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!