2013-04-20 39 views
1

我有一個由下列數據用眼跟蹤器數據R產生的熱圖

frame,X,Y 

其是從幾個眼睛跟蹤分析所得到的數據組成的表格。 現在我想創建一個使用R A熱圖,如下所示 enter image description here

我試着在網上發現了幾個劇本,他們沒有給我的結果。

我該怎麼辦?


這裏是一些樣本數據 忽略前兩列

task,visualization,frame,X,Y 
1,b,1,383,221 
1,b,1,632,356 
1,b,1,947,663 
1,b,1,546,206 
1,b,1,488,272  
1,b,1,578,752 
1,b,1,415,261 
1,b,1,693,158 
1,b,1,684,528 
1,b,1,592,67 
1,b,1,393,180 
1,b,1,1033,709 
1,b,1,1080,739 
1,b,1,711,523 
1,b,1,1246,49 
1,b,1,742,69 
1,b,1,601,370 
1,b,10,902,684 
1,b,10,517,241 
1,b,10,583,86 
1,b,10,582,754 
1,b,10,426,257 
1,b,10,575,229 
1,b,10,697,150 
1,b,10,379,520 
1,b,10,390,286 
1,b,10,618,396 
1,b,10,710,143 
1,b,10,383,188 
1,b,10,1026,713 
1,b,10,1078,625 
1,b,10,713,521 
+1

請您的情況可重複的,即我們提供數據和代碼模仿你的情況所需的代碼。有關如何執行此操作的更多提示,請參閱http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example。 – 2013-04-20 09:11:21

+0

您不知何故需要對您的圖像進行「地理配準」,並從那裏「簡單」地進行核心處理。 – 2013-04-20 09:27:34

回答

6

你可以得到這種類型的情節很容易使用stat_bin2dggplot2

library(ggplot2) 
ggplot(dat, aes(x = X, y = Y)) + stat_bin2d(bins = 10) 

enter image description here

這個 做簡單的分箱,因爲@RomanLustrik建議你也可以執行某種內核平滑。這也可以使用ggplot2完成:

ggplot(dat, aes(x = X, y = Y)) + 
stat_density2d(geom = "tile", aes(fill = ..density..), contour = FALSE) + 
geom_point() 

enter image description here 注意dat是你給的數據。例如,您的數據歌廳爲data.frame

dat = read.table(textConnection("task,visualization,frame,X,Y 
    1,b,1,383,221 
    1,b,1,632,356 
    1,b,1,947,663 
    1,b,1,546,206 
    1,b,1,488,272  
    1,b,1,578,752 
    1,b,1,415,261 
    1,b,1,693,158 
    1,b,1,684,528 
    1,b,1,592,67 
    1,b,1,393,180 
    1,b,1,1033,709 
    1,b,1,1080,739 
    1,b,1,711,523 
    1,b,1,1246,49 
    1,b,1,742,69 
    1,b,1,601,370 
    1,b,10,902,684 
    1,b,10,517,241 
    1,b,10,583,86 
    1,b,10,582,754 
    1,b,10,426,257 
    1,b,10,575,229 
    1,b,10,697,150 
    1,b,10,379,520 
    1,b,10,390,286 
    1,b,10,618,396 
    1,b,10,710,143 
    1,b,10,383,188 
    1,b,10,1026,713 
    1,b,10,1078,625 
    1,b,10,713,521"), header = TRUE, sep = ",")