Hello, I am entirely new to this list, and not very experienced with R yet (but very excited about it!!). I am struggling with a dataset of x and y coordinate points I am plotting as a density map as follows: trial <- read.csv(file="F12.csv", sep=",", skip=32, head=TRUE) trial.sub <- subset(trial, Seconds>=30) trial.sub <- subset(trial.sub, Seconds<=1830) d <- trial.sub require(MASS) dens <- kde2d(d$x, d$y, h=20, n=100) color <- function(x)rev(heat.colors(x)) filled.contour(dens, color.palette = color) Each file contains 53000 observations (29 per second), so 53000 x and y coordinates. I have posted a sample of my heat map here: https://picasaweb.google.com/neurosci.christine/Public?authkey=Gv1sRgCLO3m6Obpsr_sgE#5619604653154721794 My main question I can't seem to find an answer to is what the numbers in the legend mean. The heatmap is created for coordinate points of a location occupied by an animal, so the high density means the animal spent most of its time there, but what percentage of time? if is possible to get this out of the data and/or displayed more clearly in the legend? I addition, I would like to quantify the area size of the highest density region. Alternatively or in addition to this, I wouldn't mind measuring how many 'zones' the highest density region occupies. This might be more difficult, unless I can overlay a grid overtop of the data and count the number of zones covered. I have tried different strategies for this, including creating subsets of the coordinate point ranges, but I couldn't get it to work and any input will be greatly appreciated. To see a sample of another heatmap where this would be very relevant is posted here: https://picasaweb.google.com/neurosci.christine/Public?authkey=Gv1sRgCLO3m6Obpsr_sgE#5619604756338447826 I really appreciate any help I could get with this! I've been working on it for a week and not getting any further ahead. Christine Below is some of the data posted in case it might be helpful: Tracking area (x1 125 7 547 482 Zone1-1 (x1 127 3 273 130 Zone2-2 (x1 272 5 412 131 Zone3-3 (x1 413 7 556 128 Zone4-4 (x1 128 128 274 239 Zone5-5 (x1 273 128 415 245 Zone6-6 (x1 417 129 555 245 Zone7-7 (x1 127 239 272 348 Zone8-8 (x1 273 243 418 347 Zone9-9 (x1 416 243 554 347 Zone10-10 (x1 125 345 274 475 Zone11-11 (x1 273 346 419 474 Zone12-12 (x1 419 347 556 473 Ruler1-x (x1 178 434 506 446 70 Ruler2-y (x1 173 28 178 434 70 PointDist1-tankcenter (centrex 347 234 338 27 35 Seconds x y FishMovement Confidence Confidence>30 Zone1-1 Zone2-2 Zone3-3 Zone4-4 Zone5-5 Zone6-6 Zone7-7 Zone8-8 Zone9-9 Zone10-10 Zone11-11 Zone12-12 Ruler1-x Ruler2-y PointDist1-tankcenter 17.283 336 244 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 32.1929 37.5818 2.51121 17.317 309 217 37.6572 9.72 0 0 0 0 0 1 0 0 0 0 0 0 0 26.2279 32.87 7.03213 17.35 282 191 37.6572 13.5066 0 0 0 0 0 1 0 0 0 0 0 0 0 20.2707 28.3306 13.1651 17.383 255 165 37.6572 26.64 0 0 0 0 1 0 0 0 0 0 0 0 0 14.3135 23.7912 19.4261 17.417 228 139 150.629 35.8 1 0 0 0 1 0 0 0 0 0 0 0 0 8.35623 19.2518 25.7218 17.45 229 138 1.41421 37.6066 1 0 0 0 1 0 0 0 0 0 0 0 0 8.56156 19.0815 25.6962 17.483 228 137 1.41421 36.9029 1 0 0 0 1 0 0 0 0 0 0 0 0 8.34064 18.907 25.9339 17.517 227 136 1.41421 41.045 1 0 0 0 1 0 0 0 0 0 0 0 0 8.11971 18.7325 26.1715 17.55 226 136 1 43.4089 1 0 0 0 1 0 0 0 0 0 0 0 0 7.90658 18.7304 26.3026 17.583 224 137 2.23607 51.268 1 0 0 0 1 0 0 0 0 0 0 0 0 7.48812 18.8985 26.4611 17.617 222 137 2 46.4509 1 0 0 0 1 0 0 0 0 0 0 0 0 7.06186 18.8943 26.7272 17.65 222 137 0 44.01 1 0 0 0 1 0 0 0 0 0 0 0 0 7.06186 18.8943 26.7272 17.684 220 138 2.23607 47.0277 1 0 0 0 1 0 0 0 0 0 0 0 0 6.6434 19.0624 26.8927 17.717 219 138 1 54.1086 1 0 0 0 1 0 0 0 0 0 0 0 0 6.43027 19.0603 27.0276 17.75 218 137 1.41421 43.4641 1 0 0 0 1 0 0 0 0 0 0 0 0 6.20934 18.8858 27.2641 17.784 218 138 1 48.685 1 0 0 0 1 0 0 0 0 0 0 0 0 6.21714 19.0582 27.1629 17.817 217 139 1.41421 51.76 1 0 0 0 1 0 0 0 0 0 0 0 0 6.01181 19.2284 27.1986 17.85 215 141 2.82843 52.589 1 0 0 0 1 0 0 0 0 0 0 0 0 5.60114 19.569 27.2762 17.884 215 142 1 48.4927 1 0 0 0 1 0 0 0 0 0 0 0 0 5.60894 19.7414 27.1792 17.917 214 144 2.23607 49.7199 1 0 0 0 1 0 0 0 0 0 0 0 0 5.41141 20.084 27.1272 17.951 212 145 2.23607 60.0076 1 0 0 0 1 0 0 0 0 0 0 0 0 4.99295 20.2522 27.3143 17.984 211 147 2.23607 49.1309 1 0 0 0 1 0 0 0 0 0 0 0 0 4.79541 20.5948 27.272 18.017 210 149 2.23607 50.4243 1 0 0 0 1 0 0 0 0 0 0 0 0 4.59788 20.9375 27.2348 18.051 208 151 2.82843 54.3917 1 0 0 0 1 0 0 0 0 0 0 0 0 4.18721 21.278 27.3477 18.084 207 153 2.23607 59.2032 1 0 0 0 1 0 0 0 0 0 0 0 0 3.98968 21.6206 27.3221 18.117 206 155 2.23607 57.2786 1 0 0 0 1 0 0 0 0 0 0 0 0 3.79214 21.9633 27.3018 18.151 206 154 1 55.5511 1 0 0 0 1 0 0 0 0 0 0 0 0 3.78435 21.7909 27.3847 18.184 204 156 2.82843 57.7186 1 0 0 0 1 0 0 0 0 0 0 0 0 3.37368 22.1314 27.5157 18.217 203 157 1.41421 45.8427 1 0 0 0 1 0 0 0 0 0 0 0 0 3.16835 22.3017 27.5841 18.251 202 159 2.23607 51.1054 1 0 0 0 1 0 0 0 0 0 0 0 0 2.97082 22.6443 27.5763 18.284 201 161 2.23607 57.2206 1 0 0 0 1 0 0 0 0 0 0 0 0 2.77328 22.987 27.5737 18.318 199 163 2.82843 62.3262 1 0 0 0 1 0 0 0 0 0 0 0 0 2.36262 23.3275 27.7285 18.351 198 164 1.41421 58.4776 1 0 0 0 1 0 0 0 0 0 0 0 0 2.15728 23.4978 27.8087 18.384 197 165 1.41421 64.2789 1 0 0 0 1 0 0 0 0 0 0 0 0 1.95195 23.6681 27.8906 18.418 197 166 1 64.3908 1 0 0 0 1 0 0 0 0 0 0 0 0 1.95975 23.8404 27.8205 18.451 196 167 1.41421 61.3067 1 0 0 0 1 0 0 0 0 0 0 0 0 1.75442 24.0107 27.9055 18.484 195 167 1 56.2617 1 0 0 0 1 0 0 0 0 0 0 0 0 1.54129 24.0086 28.06 18.518 193 170 3.60555 55.5843 1 0 0 0 1 0 0 0 0 0 0 0 0 1.13842 24.5215 28.1711 18.551 192 171 1.41421 53.9743 1 0 0 0 1 0 0 0 0 0 0 0 0 0.933091 24.6918 28.2631 18.584 191 175 4.12311 55.793 1 0 0 0 1 0 0 0 0 0 0 0 0 0.751151 25.3792 28.1736 18.618 191 178 3 60.9063 1 0 0 0 1 0 0 0 0 0 0 0 0 0.774543 25.8964 27.9984 18.651 191 180 2 56.5543 1 0 0 0 1 0 0 0 0 0 0 0 0 0.790138 26.2411 27.886 18.685 189 182 2.82843 53.4996 1 0 0 0 1 0 0 0 0 0 0 0 0 0.379474 26.5817 28.0981 18.718 187 183 2.23607 56.7465 1 0 0 0 1 0 0 0 0 0 0 0 0 -0.0389871 26.7498 28.3674 18.751 187 184 1 49.3128 1 0 0 0 1 0 0 0 0 0 0 0 0 -0.0311897 26.9222 28.3166 18.785 186 187 3.16228 52.0791 1 0 0 0 1 0 0 0 0 0 0 0 0 -0.220927 27.4372 28.3317 18.818 186 190 3 50.138 1 0 0 0 1 0 0 0 0 0 0 0 0 -0.197535 27.9544 28.1939 18.851 186 191 1 59.6442 1 0 0 0 1 0 0 0 0 0 0 0 0 -0.189737 28.1268 28.1498 18.885 186 193 2 49.6857 1 0 0 0 1 0 0 0 0 0 0 0 0 -0.174142 28.4716 28.0645 18.918 188 195 2.82843 43.124 1 0 0 0 1 0 0 0 0 0 0 0 0 0.267711 28.8206 27.6548 18.952 188 197 2 50.1387 1 0 0 0 1 0 0 0 0 0 0 0 0 0.283306 29.1654 27.5763 18.985 188 199 2 57.1661 1 0 0 0 1 0 0 0 0 0 0 0 0 0.298901 29.5101 27.5017 19.018 187 200 1.41421 54.397 1 0 0 0 1 0 0 0 0 0 0 0 0 0.093569 29.6804 27.6311 19.052 187 202 2 53.8919 1 0 0 0 1 0 0 0 0 0 0 0 0 0.109164 30.0252 27.5629 19.085 188 204 2.23607 51.2277 1 0 0 0 1 0 0 0 0 0 0 0 0 0.337888 30.3721 27.3326 19.118 188 206 2 50.1443 1 0 0 0 1 0 0 0 0 0 0 0 0 0.353483 30.7168 27.272 19.152 188 206 0 53.5088 1 0 0 0 1 0 0 0 0 0 0 0 0 0.353483 30.7168 27.272 19.185 190 207 2.23607 50.202 1 0 0 0 1 0 0 0 0 0 0 0 0 0.787539 30.8935 26.9102 19.218 192 209 2.82843 56.5734 1 0 0 0 1 0 0 0 0 0 0 0 0 1.22939 31.2425 26.5214 19.252 193 210 1.41421 59.6725 1 0 0 0 1 0 0 0 0 0 0 0 0 1.45032 31.417 26.3281 19.285 195 211 2.23607 54.0302 1 0 0 0 1 0 0 0 0 0 0 0 0 1.88438 31.5936 25.9685 19.319 196 213 2.23607 60.698 1 0 0 0 1 0 0 0 0 0 0 0 0 2.1131 31.9405 25.7528 19.352 197 215 2.23607 63.1126 1 0 0 0 1 0 0 0 0 0 0 0 0 2.34182 32.2874 25.5408 19.385 197 216 1 60.0831 1 0 0 0 1 0 0 0 0 0 0 0 0 2.34962 32.4598 25.5202 19.419 197 216 0 63.885 1 0 0 0 1 0 0 0 0 0 0 0 0 2.34962 32.4598 25.5202 19.452 198 217 1.41421 62.8781 1 0 0 0 1 0 0 0 0 0 0 0 0 2.57055 32.6343 25.3328 19.485 199 218 1.41421 64.7832 1 0 0 0 1 0 0 0 0 0 0 0 0 2.79147 32.8088 25.1462 [[alternative HTML version deleted]]