Creating filled contour plots

In this recipe, we will learn how to make a contour plot with the areas between the contours filled with a solid color.

Getting ready

We will only use the base graphics functions for this recipe. So, just open up the R prompt and type the following code. We will use the inbuilt volcano dataset, so we need not load anything.

How to do it...

Let's make a filled contour plot showing the terrain data of the Maunga Whau volcano in R's in-built volcano dataset:

filled.contour(x = 10*1:nrow(volcano),y = 10*1:ncol(volcano), z = volcano, color.palette = terrain.colors, plot.title = title(main = "The Topography of Maunga Whau", xlab = "Meters North",ylab = "Meters West"), plot.axes = {axis(1, seq(100, 800, by = 100)) axis(2, seq(100, ...

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.