I wanted to fit a continuous function to a discrete 2D distribution in R. I managed to do this by using nls, and wanted to display the data. I discovered a nice way to compare the actual data and the fit using ggplot2, where the background is the real data and the circles are the fitted data (the legend is not optimal, but for a slide/figure it’s probably easier to fix it in Illustrator):
|A not-so-good fit|
|A better fit|
My data frame includes these columns: x, y, enrichment (the real data), pred (my fitted values).