0

1つのプロットにプロットしたいデータセットが2つあると仮定します。

たとえば、次のようなものです。

low <- runif(10,min=10, max=50)
high <- runif(10,min=10000, max=11000)
plot(
     high,
     type="l",
     ylim=c(0,11000)
)
lines(low, type="l")

これらのサンプルの間にあるすべての値をy軸に表示したくないのは、lowバリエーションがある場合でも、データがフラットラインとして表示されるためです。

したがって、軸には10〜50の細かい目盛りが必要であり、50〜10000の値は省略されている必要があります。また、間隔[10000-11000]にも細かい目盛りの目盛りが必要です。したがって、lowサンプルの変動も表示されます。

この動作を実現する方法はありますか?

これが見つかった場合、bt

4

2 に答える 2

1

これは役に立つでしょうか...?

set.seed(001)    
low <- runif(10,min=10, max=50)

high <- runif(10,min=10000, max=11000)
plot(
  high,
  type="l",
  ylim=c(0,11000)
)
lines(low, type="l")


plot(high,            
     type="l",              
     col="red",              
     bty='l',                
     ylab='', xlab='',      
     las=1,                 
     cex.axis=.75)     

par(new=TRUE)                

plot(low,
     type="l", 
     col="blue", 
     bty='n',                
     xaxt="n",               
     yaxt="n",               
     xlab="", ylab="", 
     cex.axis=.75)

axis(4, las=1, cex.axis=.75) 

legend('topright', c('high', 'low'), col=c('red', 'blue'), lty=1, bty='n', cex=.75)

ここに画像の説明を入力

于 2012-11-20T16:09:23.210 に答える
0

優れたグラフィカルな実践に関する質問はさておき、これはplotrixパッケージを使用して実行できます。

low <- runif(10,min=10, max=50)
high <- runif(10,min=10000, max=11000)
y <- c(low,high)
x <- rep(1:10,times = 2)

library(plotrix)
yl <- c(pretty(5:70,2),pretty(9900:11000,5))
gap.plot(x,y,
        gap = c(70,9900),
        gap.axis = "y",
        ytics = yl,
        type = "l")

ここに画像の説明を入力

于 2012-11-20T16:06:53.953 に答える