Creating contour plots
In this recipe, we will learn how to make contour plots to visualize topographical data, such as the terrain near a mountain or a volcano.
Getting ready
We are only using 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 first make a default contour plot with volcano
:
contour(x=10*1:nrow(volcano), y=10*1:ncol(volcano), z=volcano, xlab="Metres West",ylab="Metres North", main="Topography of Maunga Whau Volcano")
How it works...
We used the contour()
base graphics library function to make ...
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.