7

次のデータ例を見てください。

x <- rnorm(10000)
y <- rnorm(10000) * x
z <- rnorm(10000) * y
df <- data.frame(x,y,z)

次のように散布図行列を作成できます。

splom(df)

ここに画像の説明を入力してください

ただし、重なり合うポイントの数が多いため、密度を測定するのは困難です。

各プロットを、スカッシュによって生成されたもののような2変量ヒストグラムヒートマップに置き換える簡単な方法はありますか?

library(squash)
hist2(df$x, df$y)

ここに画像の説明を入力してください

4

3 に答える 3

8

panel.hexbinplot大規模なデータセットに便利です。

library(hexbin)
splom(df, panel=panel.hexbinplot)

ここに画像の説明を入力してください

次のようにパネル機能をカスタマイズできます。

library(hexbin)
splom(df,
      panel = function(x, y, ...){
        panel.hexbinplot(x, y, style = "nested.lattice", 
                      type = c("g", "smooth"),col='blue', ...)
      },
      pscale=0, varname.cex=0.7)

パラメータで遊ぶことができstyleます。

ここに画像の説明を入力してください

于 2013-02-05T02:30:16.290 に答える
4

元のリクエストとより一致する別のオプションがあります

# run the code you've provided
library(lattice)
x <- rnorm(10000)
y <- rnorm(10000) * x
z <- rnorm(10000) * y
df <- data.frame(x,y,z)

# look at each of these options one-by-one..  go slowly!

# here's your original
splom(df)


# here each point has been set to very transparent
splom(df , col="#00000005" )

ここに画像の説明を入力してください

# here each point has been set to moderately transparent
splom(df , col="#00000025" )

ここに画像の説明を入力してください

# here each point has been set to less transparent
splom(df , col="#00000050" )

ここに画像の説明を入力してください

于 2013-02-05T02:04:08.430 に答える
0

これはあなたが求めた方法ではありませんが、あなたが説明した根本的な問題を解決するのに役立ちます:)

# run the code you've provided
library(lattice)
x <- rnorm(10000)
y <- rnorm(10000) * x
z <- rnorm(10000) * y
df <- data.frame(x,y,z)

# figure out what ten percent of the total records are
ten.percent <- nrow( df ) / 10

# create a new data frame `df2` containing
# a randomly-sampled ten percent of the original data frame
df2 <- df[ sample( nrow( df ) , ten.percent  ) , ]

# now `splom` that.. and notice it's easier to see densities
splom(df2)
于 2013-02-05T01:58:17.443 に答える