2017-05-15 48 views
0

로그 스케일 y 축을 통합해야하는 간단한 ggplot에 문제가 있습니다. ggplot은 로그 스케일이있는 축을 그리면 곡선을 그리는 것이 옳다는 것을 이해합니다. 라인은 여전히 ​​데이터 포인트를 선형 적으로 연결합니다.ggplot 로그 스케일 y 축 직선

forexample<-transform(example, EXP=factor(EXP, levels=unique(EXP))) 
plot<-ggplot(forexample, aes(x=EXP, y=concentration, shape=sample)) 
+ stat_summary(aes(group = sample), fun.y = mean, geom = 'line', alpha=1, size=0.5) 
+ stat_summary(aes(group = sample), fun.y = mean, geom = 'point', alpha=1, size=4) + 
theme_bw() + 
coord_trans(y = "log10") 

내 데이터는 다음과 같이 구성되어있다 :

sample concentration EXP 
H  0.08   Ex1 
H  0.07   Ex2 
M  2.00   Ex1 
M  0.50   Ex2 
R  0.01   Ex1 

...

내가 질문 "Y의 규모를 기록 ggplot2에 Zoltáns 제안을 시도

내 코드입니다 곡선을 야기하는 축 "그러나 그것은 나를 위해 잘되지 않았다. ( ggplot2 log scale of y axis causing curved lines)

누군가가 나를 도울 수 있다면 정말 기뻐할 것입니다! 감사합니다 :)

enter image description here

답변

2

coord_trans의 의도 된 행동이며, scale_y_log10 구별된다. 참조 : 당신이 y 축 레이블과 눈금 선이 더 coord_trans 기본 설정과 같이보고 싶은 경우, scale_y_log10(breaks = scales::pretty_breaks())를 사용 https://stackoverflow.com/a/25257463/3330437

require(dplyr) # for data construction 
require(scales) # for modifying the y-axis 

data_frame(x = rep(letters, 3), 
      y = rexp(26*3), 
      sample = rep(c("H", "M", "R"), each = 26)) %>% 
    ggplot(aes(x, y, shape = sample)) + theme_bw() + 
    geom_point() + geom_path(aes(group = sample)) + 
    scale_y_log10() 

enter image description here

.

enter image description here

+0

정말 고마워요. :) – Pauline