O'Reilly logo

R Graphs Cookbook by Hrishi Mittal

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating filled contour plots

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

Getting ready

We are only using the base graphics functions for this recipe. So, just open up the R prompt and type the code we are about to see. 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 inbuilt 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, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required