就像标题说的那样。我有一幅想要提取颜色的十六进制值的图像,将其存储在data.frame中,然后使用ggplot进行绘制。
这就是我所拥有的:
library(ggplot2)
aws.logo = 'https://eventil.s3.amazonaws.com/uploads/group/avatar/8626/medium_highres_470196509.jpeg'
temp = tempfile()
download.file(aws.logo, temp, mode = 'wb')
## matrix of colors
y = jpeg::readJPEG(temp)
val <- rgb( y[,,1], y[,,2], y[,,3], maxColorValue = 255)
aws.img <- matrix(val, dim(y)[1], dim(y)[2])
out = reshape2::melt(aws.img)
names(out) = c('col', 'row', 'value')
out$value = as.character(out$value)
ggplot(out) +
geom_point(aes(x = row, y = -col), color = out$value) + ## why do I have to flip the order of
theme(legend.position="none") ## col after reshaping?
为什么颜色与网站上的徽标不同?