2017-05-15 13 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

関連する問題