Data Visualization: Scatter Plot step by step with R

In continuation to my previous post on scatter plot which was more of an introduction, in this post we will see step by step approach on doing scatter plot with R. Our objective in this post would be to draw a scatter plot using R step by step.


The following table provides the data which will be used in this post. This has two columns one is “Year” and another one is “Total Telephones” which is in millions.


 Source Data:


Step 1: We have this data in a CSV file named “ScatterPlotData.csv”

Step 2: We will load this data using load.csv method using mydata=read.table(“E:\\Personal\\Learning\\Data Visualization\\ScatterPlotData.csv”,header=TRUE). This will handle the header and load the data appropriately.

Step 3: Now we have the data in mydata

Step 4: Now we can plot the Graph using the following statement :

mydata=read.table("E:\\Personal\\Learning\\Data Visualization\\ScatterPlotData.csv",header=TRUE)
plot(mydata$Year,mydata$TotalTelephones,main="Year Vs Sale of Telephones",xlab="Year",ylab="Sale of Telephones(Millions)",xaxt="n",ann="True")
axis(1, at=1:length(mydata$Year), lab=c(2004,2005,2006,2007,2008,2009,2010,2011,2012,2013))

Step 5: The Result


Data Visualization: Scatter Plot

Scatter Plot

Scatter plot is a graph where in two variables are plotted against X and Y Axes. The plotted data might reveal the correlation between the two variables plotted.


Visual Look:

Scatter plots are similar to line graphs. The only difference is a line graph has a continuous line while a scatter plot has a series of dots. 

Primary goal:

This type of plot is used to identify relationship between the two variables. The relationship could indicate the following:

  • Strength
  • Shape – Linear, Curved, etc.,
  • Direction – Positive or Negative
  • Presence of Outliers

When do we use it?

  • When we need to understand the cause-and-effect relationship
  • When we need to understand the relationship between two variables.

Example scenarios:

  • Age and weight
  • Variation in sales based on certain conditions (E.g., Temperature in the City, Event,etc.,)
  • Increase in adoption of telephones over the years


Example of Scatter Plot done in Excel:

Source Data:




In the next post we will see how we can do the same with “R”.