ggplot 배경으로 사용되는 rastergrob 객체에 투명도를 추가하고 싶습니다.R - gprplot의 rastergrob 배경에 투명도 추가
여기에 내 코드
library(ggplot2)
library(grid)
library(ggthemes)
reds <- c("brown", "red","orange","green","orange","red","brown","grey")
g <- rasterGrob(reds, width = unit(1, "npc"), height = unit(1,"npc"),interpolate = TRUE)
p <- ggplot(data = economics, aes(x = date, y = unemploy)) +
annotation_custom(g, xmin=-Inf, xmax=Inf, ymin=-Inf, ymax=Inf)+
geom_line(alpha=1, color = "white", size = 0.5) +
xlab("Years") + ylab("Unemployed [thousands]") +
theme_base() +
theme(panel.background=element_blank(),
plot.background=element_blank(),
line = element_line(colour="white")) +
theme()
grid.newpage()
print(p, newpage = FALSE)
내가 annotation_custom에서 둘의 rastergrob에 알파를 추가 할 수 있습니다. 나는 잠시 동안 찾고 있었다.
숫자 값을 사용해 보셨습니까? 예 : "red"대신 "# F5262688"을 사용하십시오. – G5W
음, 내 벡터의 모든 색상을 투명하게 동등하게 변환 할 수있는 "adjustcolor"함수를 찾았습니다. 감사 ! – jakzr
아마도 자신의 질문에 대한 답변을 게시하여 사람들이 답변을 받았음을 알 수 있습니다. – G5W