How to calculate gradient with multiple color sizes in R

this is related to this question , but perhaps a simpler example. I am curious if there is a reasonable way to calculate a multidimensional color gradient, given three or four arbitrary colors, as the r function does rgb()with red, green, blue? the one-dimensional gradient is simple (Fig. 1), but then it is not clear to me how to calculate the two-dimensional gradient (Fig. 2) inside the triangle . the edges are light. this is what is considered inside

# one dimensional color gradient
one.dimensions <- colorRampPalette( c( "orange" , "blue" ) )( 100 )

plot( 1:100 , rep( 1 , 100 ) , col = one.dimensions , cex = 3 , pch = 16 , main  = 'one dimensional gradient' )

enter image description here

# here are the edges of a three-colored triangle
dimensions13 <- colorRampPalette( c( "orange" , "blue" ) )( 100 )
dimensions12 <- colorRampPalette( c( "orange" , "red" ) )( 100 )
dimensions23 <- colorRampPalette( c( "blue" , "red" ) )( 100 )

plot( 1:100 , c( 1:50 , 50:1 ) , type = 'n' , main = 'two dimensional gradient' )
points( 1:100 , rep( 1 , 100 ) , col = dimensions12 , cex = 3 , pch = 16 )
points( seq( 1 , 50 , length = 100 ) , seq( 1 , 50 , length = 100 ) , col = dimensions13 , cex = 3 , pch = 16 )
points( seq( 50 , 100 , length = 100 ) , seq( 50 , 1 , length = 100 ) , col = dimensions23 , cex = 3 , pch = 16 )

enter image description here

+4
source share
1 answer

You can consider three basic color mixing strategies:

1- , - R. , .

library(grid)

grid.newpage()
grid.raster(scales::alpha(colorRampPalette(c("white","blue"))(10), 0.3),
            width=1,height=1)
grid.raster(t(scales::alpha(colorRampPalette(c("white","red"))(10), 0.3)),
            width=1,height=1)

, .

enter image description here

CMYK .

2- . . (, , , ). (570 , 520 , 600 ). ( N ). , , N , CIE. , . , , : , , . , N > 3 .

3- pixelated (halftoning). , , -, N , . - / / .

+2

All Articles