2014-04-01 3 views
1

'x'값을 1에서 10까지 사용하여 수동으로 지정한 색상의 투명도를 제어하고 싶습니다. 'alpha = x'를 추가하면됩니다. 그러나이 경우에는 어두운 색 점 내 산란 음모에. 아무도 도와 줄 수 있니?ggplot2의 색상 투명도 제어

여기 내 코드입니다 :

plot1 <- qplot(data=srna[srna$norm_sum > 0 & srna$len > 18 & srna$len < 25, ], x=position,y=norm_sum,colour= len) 
plot1 + geom_point(size=4) + 
    theme_bw()+ 
# scale_alpha_continuous(range = c(0.1, 0.8))+ 
    scale_colour_manual(values = c("19" = "pink","20" = "blue","21" = "green", "22" = "yellow","23" = "violet", "24" = "red"))+ 
    theme(panel.grid.minor.x = element_line(colour='grey94'),panel.grid.minor.y = element_line(colour='grey94'), 
     panel.grid.major.x = element_line(colour='lightgrey'),panel.grid.major.y = element_line(colour='lightgrey')) 
+1

당신은 당신의 데이터가 어떻게 생겼는지의 표시를 추가시겠습니까? 'head (srna)'가 적합합니다. "짙은 색 점"은 무엇을 의미합니까? 또한 알파를 수동으로 지정하려는 이유를 설명 할 수 있습니까? 마지막으로 [scale_alpha_manual] (http://docs.ggplot2.org/current/scale_manual.html)을 보셨습니까? – naught101

답변

0

the ggplot2 manual에서 기본 데이터를 사용하여 질문 (아래 코드)를 재현하는 시도하고 나는이 결과를 얻었다. 어쩌면 여기서 문제가 무엇인지 지적 할 수 있을까요?

geom_point, control color transparency in ggplot2

# install.packages("ggplot2", dependencies = TRUE) 
library(ggplot2) 
p <- ggplot(mtcars, aes(wt, mpg)) 
p + geom_point(size=4, alpha = 0.5, aes(colour = factor(cyl))) + 
     theme_bw() + 
    scale_colour_manual(values = c("4" = "pink","6" = "blue", "8" = "green")) + 
    theme(panel.grid.minor.x = element_line(colour='grey94'), 
      panel.grid.minor.y = element_line(colour='grey94'), 
      panel.grid.major.x = element_line(colour='lightgrey'), 
      panel.grid.major.y = element_line(colour='lightgrey')) 
관련 문제