Creating a Heat Map from (X,Y) Corrdinates in R

Construct R heatmap from specified xy-coordinates and a value

I suspect you're looking for an image() plot, i.e. simple tiles on a 4x4 grid, rather than a continuous function/heatmap.
Especially if your coordinates are in the range x=1..4,y=1..4 and you have all 16 complete values.

See image() in base, or geom_tile() in ggplot2 package; or qplot(..., geom='tile')

When you say "create a heatmap (density plot?) from this data which is colored based on value at each position" you simply mean "plot a tiled image".

Plot frequency heatmap of positions from set of coordinates

As Jon Spring suggested, the following code shows up a graph like this:

all_data <- read.table(text = "
Track X1 X Y
1 Point 1 147.8333 258.5000
2 Point 2 148.5000 258.8333
3 Point 3 151.1667 260.8333
4 Point 4 154.5000 264.5000
5 Point 5 158.1667 266.5000
6 Point 6 161.5000 269.5000
", header = T, row.names = NULL)

ggplot(data=all_data, aes(x=X, y=Y)) + geom_bin2d()

Sample Image



Related Topics



Leave a reply



Submit