2017-06-29 7 views
2

単純なプロットを作成したいが、非標準ブレークを作成したい。yaxis用プロットの非標準ブレーク

私のデータのためのコードです:

> dput(dt1) 
c(15.9540654816514, 37.5416557213931, 143.317585514018, 317.329051086954, 
736.342269565211, 611.759999999995, 1145.49376842104, 3287.57274999997 
) 
> dput(dt2) 
c(7.74957214839424, 17.5499521829522, 47.8167516932271, 72.1468924428822, 
131.457629238329, 119.135097468354, 193.812365333332, 339.109355072461 
) 
> dput(dt3) 
c(3.43850794565666, 11.4081262121212, 24.6747108504399, 54.7253625128734, 
85.7360432084306, 89.7801271317832, 117.764457806452, 152.859368367347 
) 

と私はそのような何かを達成したいと思います。ただ、そのグラフ上の赤いポイントを無視

Output

を。

これまでに書いたコードです。ただし、yブレークを変更するアプローチは機能しません。

plot(dt1,col="blue",cex = 1.8,xlim=c(0,10), ylim = c(1,5000), yaxt = "n", bty="n",xlab="",ylab="") 
axis(side = 2, at = C(10,100,1000,5000) 
points(dt2,col="green",cex = 1.8) 
points(dt3,col="red",cex = 1.8) 

可能ですか?添付の画像のように同じxlabelを作成したいと思います。私は他のソフトウェアでも同様に変更することができます。

答えて

4

これは私がggplot2を使用して考えることができる最も近いです。

library(data.table) 
library(dplyr) 
library(ggplot2) 
theme_set(theme_bw()) 
dat <- rbindlist(list(
    data.table(dt = "dt1", 
      y = c(15.9540654816514, 37.5416557213931, 143.317585514018, 317.329051086954, 
      736.342269565211, 611.759999999995, 1145.49376842104, 3287.57274999997)), 
    data.table(dt = "dt2", 
      y = c(7.74957214839424, 17.5499521829522, 47.8167516932271, 72.1468924428822, 
        131.457629238329, 119.135097468354, 193.812365333332, 339.109355072461)), 
    data.table(dt = "dt3", 
      y = c(3.43850794565666, 11.4081262121212, 24.6747108504399, 54.7253625128734, 
        85.7360432084306, 89.7801271317832, 117.764457806452, 152.859368367347)))) 

## generate lables 
labs <- paste(rep(1:4, c(2,3,2,1)), rep(c(1,2,3,4,3,4), c(1,2,1,1,1,2)), sep = '\n-\n') 
## create x variable 
dat[, x := rep(1:8, 3) %>% factor(labels = labs)] 
## plot 
ggplot(dat, aes(x = x, y = y, colour = dt)) + 
    geom_point() + 
    scale_y_log10(limits = c(1, 10000), 
       breaks = 10^(0:4)) + 
    xlab("") + ylab("") 
ggsave('temp.png', width = 4, height = 3) 

出力は次のようになります。 enter image description here

関連する問題