지정된 색상의 플롯입니다.ggplot2의 geom_text에 색상 목록을 할당합니다.
#color generatering
map2col<-function(x,pal,limits=NULL){
if(is.null(limits)) limits=range(x)
pal[findInterval(x,seq(limits[1],limits[2],length.out=length(pal)+1), all.inside=TRUE)]
}
tmpC <- map2col(mtcars$cyl, c("red", "blue", "yellow"))
#plot
p <- ggplot(mtcars, aes(x=wt, y=mpg, label=rownames(mtcars)))
p + geom_text(aes(colour=tmpC))
질문 : tmpC에서 할당 한 색상이 작동하지 않습니다. tmpC로 col을 할당하는 방법은 무엇입니까? 고맙습니다.
'scale_color_manual'을 사용하십시오. – Roland