Search code examples
rheatmapdensity-plotspatstat

Making a density plot


I am using the longleaf data in spatstat where the marks attached to each point pattern is the diameter of the trees. I have created a density colour map plot of the data. But instead of the colours relating to the density of the trees I want to colour map to relate to the diameter of the trees.

For the density colour map plot of the long leaf data I have this and I have attached the plot.

plot(density(longleaf))
plot(longleaf,add=TRUE,main=NULL,axes=TRUE)

enter image description here


Solution


  • The spatstat function Smooth() (notice the upper case S) smooths the mark values across space:

    library(spatstat)
    plot(Smooth(longleaf), main = "Smoothed tree diameters.")
    plot(longleaf, add = TRUE)