3

Rで次のタイプの不連続ヒートマップに似たものを作成したいと思います:

ここに画像の説明を入力

ここに画像の説明を入力

私のデータは次のように配置されています。

k_e percent time
 ..   ..     ..
 ..   ..     ..

k_ex 軸、percenty 軸になりtime、色を示したいと思います。

私が見つけることができるすべてのリンクは、連続行列 http://www.r-bloggers.com/ggheat-a-ggplot2-style-heatmap-function/または補間をプロットしました。しかし、私は上記のどちらも望んでいません。上の画像のように不連続なヒートマップをプロットしたいと思います。

4

2 に答える 2

3

2 つ目は hexbin プロットです (x,y) ペアが一意である場合は、xy プロットを実行できます。それが必要な場合は、ベース R プロット関数を使用して試すことができます。

x <- runif(100)
y<-runif(100)
time<-runif(100)

pal <- colorRampPalette(c('white','black'))
#cut creates 10 breaks and classify all the values in the time vector in
#one of the breaks, each of these values is then indexed by a color in the
#pal colorRampPalette.

cols <- pal(10)[as.numeric(cut(time,breaks = 10))]

#plot(x,y) creates the plot, pch sets the symbol to use and col the color 
of the points
plot(x,y,pch=19,col = cols)

ggplot を使用すると、次のことも試すことができます。

library(ggplot2)
qplot(x,y,color=time)
于 2015-01-30T12:37:08.377 に答える
1

データの生成

d <- data.frame(x=runif(100),y=runif(100),w=runif(100))

使用するggplot2

require(ggplot2)

サンプル数

次のコードは、色がビンに分類されるアイテムの数を表す不連続なヒートマップを生成します。

ggplot(d,aes(x=x,y=y)) + stat_bin2d(bins=10)

ここに画像の説明を入力

平均体重

w次のコードは、現在のビン内のすべてのサンプルの変数の平均値を色で表す不連続ヒートマップを作成します。

ggplot(d,aes(x=x,y=y,z=w)) + stat_summary2d(bins=10)

ここに画像の説明を入力

于 2015-01-30T13:11:42.390 に答える