# Comparing two-dimensional data sets in R

[This article was first published on

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

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):**bioCS**, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

A not-so-good fit |

A better fit |

My data frame includes these columns: x, y, enrichment (the real data), pred (my fitted values).

To

**leave a comment**for the author, please follow the link and comment on their blog:**bioCS**.R-bloggers.com offers

**daily e-mail updates**about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.