2014-12-23 4 views
2

ggplot alpha가 내 음모에 충분히 어두워 지도록하는 데 문제가 있습니다.ggplot : alpha/fill 두 가지 요인 조정 cdf

예제 코드 : carb == 1, 그것은 플롯 요소를 보는 것은 매우 어려운 일 때마다

ggplot(mtcars, aes(x=mpg, color=factor(gear), alpha=factor(carb))) + stat_ecdf() 

enter image description here

당신이 볼 수 있듯이,. 내 실제 세계 데이터 세트에서 색상 요소는 네 가지 수준을 갖고 알파 요소는 두 가지 수준을 갖습니다. 알파를 약간 밝은 색조로 표현하고 싶지만 그 예에서 어떻게 나타나는지보다 더 잘 보입니다.

+0

은'range' 인수 봐 of' scale_alpha_discrete'; ie 'scale_alpha_discrete (범위 = c (0.4, 0.9))' – user20650

답변

3

range 또는 breaks ~ scale_alpha_discrete의 특정 집합을 지정하여 주석의 사용자가 제안하는대로 알파 배율을 조정할 수 있습니다.

ggplot(mtcars, aes(x=mpg, color=factor(gear), alpha=factor(carb))) + 
    stat_ecdf() + 
    scale_alpha_discrete(range=c(0.4, 1)) 

enter image description here

는 또 다른 옵션은 많은 평준화 요인에 대한 color을 저장하는 것과 few-에 대해 다른 미학을 선택 : 그, 그래도 아주 읽기 쉬운 결과를 생성하지 않습니다 그래도, 가독성을 위해 어쩌면 linetype

ggplot(mtcars, aes(x=mpg, linetype=factor(gear), color=factor(carb))) + 
    stat_ecdf() 

enter image description here

처럼, 하나의 수평 패시팅이 더 나은 선택이 될 수 있습니다.

ggplot(mtcars, aes(x=mpg, color=factor(carb))) + 
    stat_ecdf() + facet_wrap(~gear, nrow=3) 

enter image description here