I have a question regarding ggplot.
I have a dataset that consists of different timepoints \"time\", x and y coordinates (named X_MA and Y_MA), see an excerpt of my data
You can do something like this:
ggplot(data2,aes(x = X_MA, y = Y_MA,
color = cut(time, breaks = c(0,2,12,1000), labels = c("First two
seconds","Middle two seconds","Last period")))) +
stat_density_2d(aes(fill = ..density..), geom = "raster", contour = FALSE) +
scale_fill_distiller(palette=8, direction=-1) +
scale_x_continuous(expand = c(0, 0)) +
scale_y_continuous(expand = c(0, 0)) +
theme(legend.position='n_one') +
geom_point(size=1) +
guides(color=guide_legend(title="Time category"))
Cut
will split you data set up into intevals, which you can name here. Note that you will need to change the numbers for the intervals - I don't know what the first time reading is in your dataset, but I have left here for illustration.
The guides
bit at the bottom is there simply to name the legend.