I would like to plot a ppp object from a particle analysis in ImageJ from a greyscale image with size imageSizeX, imageSizeY of point objects Particles$X, Particles$Y in flipped Java coordinates (y0 = top-left). I have a kind of working solution (example with customization):
library(spatstat)
X <- ppp(Particles$X, Particles$Y, c(0, imageSizeX), c(0, imageSizeY))
plot(x = 0, y = 0, xlim = c(0, imageSizeX), ylim = c(imageSizeY, 0), type = "n", main = "Density",
asp = 1, axes = F, xlab = "X", ylab = "Y")
plot(density(X), xlim = c(1, imageSizeX), ylim = c(imageSizeY, 0), add = T)
plot(X, axes = TRUE, xlim = c(1, imageSizeX), ylim = c(imageSizeY, 0), add = T)
axis(1)
axis(2, las = 2)
which results in the following plot (which omits the legend):
However I need to create an empty plot command with the flipped coordinates (ylim = c(imageSizeY, 0)) and then have to add the spatstat plots.
If I try to plot:
library(spatstat)
X <- ppp(Particles$X, Particles$Y, c(0, imageSizeX), c(0, imageSizeY))
plot(density(X), xlim = c(1, imageSizeX), ylim = c(imageSizeY, 0))
plot(X, axes = TRUE, xlim = c(1, imageSizeX), ylim = c(imageSizeY, 0), add = T)
axis(1)
axis(2, las = 2)
the coordinates are not plotted flipped (ylim = c(imageSizeY, 0)):
Is there a way to flip the plot coordinates in spatstat without a first defining plot command?