I have the data here data. I want to plot the categorically marked point pattern using spatstat in R. I have tried doing this
x = c(3,0.5,1,0,0,0,2,2.5,5.5, 16,21,26,28,40, 47, 52, 58, 60, 65, 63, 63, 75, 77, 78, 75)
y = c(116,106,82.5,64,40,35,25,17.5,5,5,5,8,10,8, 14, 14, 10, 0, 0, 17, 20, 24, 30, 50, 116)
p <- owin(poly = cbind(x, y))
point_pattern = as.ppp(deviation_binary_category_locations_marks, p)
marks(point_pattern) <- deviation_binary_category_locations_marks[, "RPL32"]
ccc <- c("green","black")[marks(point_pattern)]
shapes = c(1,21)[marks(point_pattern)]
plot(point_pattern,which.marks="RPL32", main="Point pattern for gene RPL32")
plot(point_pattern,which.marks="RPL32",bg=ccc,pch = shapes, add=TRUE)
It results in a plot like this
However, the circle and the triangle are not clear without colouring I think. How can I colour the triangle so it will be more obvious to see? Or change the triangle to a coloured circle? I have tried using the code mentioned above but nothing has change.
Use argument cols
to specify colours for the different types of points, and chars
to specify the plotting symbols for the different types of points. You could also use cex
to control the size of the plot symbols to make them more distinct.
For further information see the help file for plot.ppp
.