Plotting in R

We can make a simple plot using the plot() function of R. Now we will simulate 50 values from a normal distribution using rnorm() and assign these to x and similarly generate and assign 50 normally distributed values to y. We can plot these values in the following way:

x = rnorm(50)y = rnorm(50)# pch = 19 stands for filled dotplot(x, y, pch = 19, col = 'blue')

This gives us the following scatterplot with blue-colored filled dots as symbols for each data point:

We can also generate a line plot type of graph by using type = "l" inside plot().

Now we will briefly look at a very strong graphical library called ggplot2 developed ...

Get Hands-On Geospatial Analysis with R and QGIS 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.