Creating scatter plots with a smoothed density representation

Smoothed density scatter plots are a good way of visualizing large datasets. In this recipe, we will learn how to create them using the smoothScatter() function.

Getting ready

For this recipe, we don't need to load any additional libraries. We just need to type the recipe in the R prompt or run it as a script.

How to do it...

We will use the smoothScatter() function that is part of the base graphics library. We will use an example from the help file that can be accessed from the R prompt with the help command:

n <- 10000
x  <- matrix(rnorm(n), ncol=2)
y  <- matrix(rnorm(n, mean=3, sd=1.5), ncol=2)
smoothScatter(x,y)

How it works...

The smoothScatter() function produces a smoothed color density ...

Get R: Data Analysis and Visualization now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.