R language is mostly used for statistics and data analytics purposes to represent the data graphically in the software. To represent those data graphically, charts and graphs are used in R.Â
R - graphs
There are hundreds of charts and graphs present in R. For example, bar plot, box plot, mosaic plot, dot chart, coplot, histogram, pie chart, scatter graph, etc.Â
Types of R - Charts
- Bar Plot or Bar Chart
- Pie Diagram or Pie Chart
- Histogram
- Scatter Plot
- Box Plot
Bar Plot or Bar Chart
Bar plot or Bar Chart in R is used to represent the values in data vector as height of the bars. The data vector passed to the function is represented over y-axis of the graph. Bar chart can behave like histogram by using table() function instead of data vector.Â
Syntax: barplot(data, xlab, ylab)
where:
- data is the data vector to be represented on y-axis
- xlab is the label given to x-axis
- ylab is the label given to y-axis
Note: To know about more optional parameters in barplot() function, use the below command in R console:
help("barplot")
Example:Â
R
# defining vector
x <- c(7, 15, 23, 12, 44, 56, 32)
# output to be present as PNG file
png(file = "barplot.png")
# plotting vector
barplot(x, xlab = "GeeksforGeeks Audience",
ylab = "Count", col = "white",
col.axis = "darkgreen",
col.lab = "darkgreen")
# saving the file
dev.off()
Output:Â

Pie Diagram or Pie Chart
Pie chart is a circular chart divided into different segments according to the ratio of data provided. The total value of the pie is 100 and the segments tell the fraction of the whole pie. It is another method to represent statistical data in graphical form and pie() function is used to perform the same.Â
Syntax: pie(x, labels, col, main, radius)
where,Â
- x is data vector
- labels shows names given to slices
- col fills the color in the slices as given parameter
- main shows title name of the pie chart
- radius indicates radius of the pie chart. It can be between -1 to +1
Note: To know about more optional parameters in pie() function, use the below command in the R console:Â
help("pie")
Example:Â
Assume, vector x indicates the number of articles present on the GeeksforGeeks portal in categories names(x)Â
R
# defining vector x with number of articles
x <- c(210, 450, 250, 100, 50, 90)
# defining labels for each value in x
names(x) <- c("Algo", "DS", "Java", "C", "C++", "Python")
# output to be present as PNG file
png(file = "piechart.png")
# creating pie chart
pie(x, labels = names(x), col = "white",
main = "Articles on GeeksforGeeks", radius = -1,
col.main = "darkgreen")
# saving the file
dev.off()
Output:Â
Pie chart in 3D can also be created in R by using following syntax but requires plotrix library.Â
Syntax: pie3D(x, labels, radius, main)
Note: To know about more optional parameters in pie3D() function, use below command in R console:Â
help("pie3D")
Example:Â
R
# importing library plotrix for pie3D()
library(plotrix)
# defining vector x with number of articles
x <- c(210, 450, 250, 100, 50, 90)
# defining labels for each value in x
names(x) <- c("Algo", "DS", "Java", "C", "C++", "Python")
# output to be present as PNG file
png(file = "piechart3d.png")
# creating pie chart
pie3D(x, labels = names(x), col = "white",
main = "Articles on GeeksforGeeks",
labelcol = "darkgreen", col.main = "darkgreen")
# saving the file
dev.off()
Output:Â

Histogram
Histogram is a graphical representation used to create a graph with bars representing the frequency of grouped data in vector. Histogram is same as bar chart but only difference between them is histogram represents frequency of grouped data rather than data itself.
Syntax: hist(x, col, border, main, xlab, ylab)
where:
- x is data vector
- col specifies the color of the bars to be filled
- border specifies the color of border of bars
- main specifies the title name of histogram
- xlab specifies the x-axis label
- ylab specifies the y-axis label
Note: To know about more optional parameters in hist() function, use below command in R console:Â
help("hist")
Example:Â
R
# defining vector
x <- c(21, 23, 56, 90, 20, 7, 94, 12,
57, 76, 69, 45, 34, 32, 49, 55, 57)
# output to be present as PNG file
png(file = "hist.png")
# hist(x, main = "Histogram of Vector x",
xlab = "Values",
col.lab = "darkgreen",
col.main = "darkgreen")
# saving the file
dev.off()
Output:Â

Scatter Plot
A Scatter plot is another type of graphical representation used to plot the points to show relationship between two data vectors. One of the data vectors is represented on x-axis and another on y-axis.Â
Syntax: plot(x, y, type, xlab, ylab, main)
Where,Â
- x is the data vector represented on x-axis
- y is the data vector represented on y-axis
- type specifies the type of plot to be drawn. For example, "l" for lines, "p" for points, "s" for stair steps, etc.
- xlab specifies the label for x-axis
- ylab specifies the label for y-axis
- main specifies the title name of the graph
Note: To know about more optional parameters in plot() function, use the below command in R console:Â
help("plot")
Example:Â
R
# taking input from dataset Orange already
# present in R
orange <- Orange[, c('age', 'circumference')]
# output to be present as PNG file
png(file = "plot.png")
# plotting
plot(x = orange$age, y = orange$circumference, xlab = "Age",
ylab = "Circumference", main = "Age VS Circumference",
col.lab = "darkgreen", col.main = "darkgreen",
col.axis = "darkgreen")
# saving the file
dev.off()
Output:Â
If a scatter plot has to be drawn to show the relation between 2 or more vectors or to plot the scatter plot matrix between the vectors, then pairs() function is used to satisfy the criteria.Â
Syntax: pairs(~formula, data)
where,
- ~formula is the mathematical formula such as ~a+b+c
- data is the dataset form where data is taken in formula
Note: To know about more optional parameters in pairs() function, use the below command in R console:Â
help("pairs")
Example :Â
R
# output to be present as PNG file
png(file = "plotmatrix.png")
# plotting scatterplot matrix
# using dataset Orange
pairs(~age + circumference, data = Orange,
col.axis = "darkgreen")
# saving the file
dev.off()
Output:Â

Box Plot
Box plot shows how the data is distributed in the data vector. It represents five values in the graph i.e., minimum, first quartile, second quartile(median), third quartile, the maximum value of the data vector.
Syntax: boxplot(x, xlab, ylab, notch)
where,Â
- x specifies the data vector
- xlab specifies the label for x-axis
- ylab specifies the label for y-axis
- notch, if TRUE then creates notch on both the sides of the box
Note: To know about more optional parameters in boxplot() function, use the below command in R console:Â
help("boxplot")
Example:Â
R
# defining vector with ages of employees
x <- c(42, 21, 22, 24, 25, 30, 29, 22,
23, 23, 24, 28, 32, 45, 39, 40)
# output to be present as PNG file
png(file = "boxplot.png")
# plotting
boxplot(x, xlab = "Box Plot", ylab = "Age",
col.axis = "darkgreen", col.lab = "darkgreen")
# saving the file
dev.off()
Output:Â
Similar Reads
R - Bar Charts Bar charts provide an easy method of representing categorical data in the form of bars. The length or height of each bar represents the value of the category it represents. In R, bar charts are created using the function barplot(), and it can be applied both for vertical and horizontal charts.Syntax
4 min read
R - Pie Charts A pie chart is a circular statistical graphic, which is divided into slices to illustrate numerical proportions. It depicts a special chart that uses "pie slices", where each sector shows the relative sizes of data. A circular chart cuts in the form of radii into segments describing relative frequen
4 min read
Difference between Graphs and Charts Graphs and Charts are both visual representations of data, but they serve slightly different purposes and are used in different contexts. Graphs are more about exploring relationships between variables and are often used in more technical or scientific contexts. However, Charts are about presenting
5 min read
Basic Python Charts Python Chart is part of data visualization to present data in a graphical format. It helps people understand the significance of data by summarizing and presenting huge amounts of data in a simple and easy-to-understand format and helps communicate information clearly and effectively. In this articl
6 min read
Chart.js Chart Types In this article, we will explore some of the key chart types provided by Chart.js, covering their descriptions, syntax, examples, and outputs.Chart.js offers a diverse set of chart types, each designed to convey specific types of data effectively. It also helps to see the computed data at a glance,
4 min read
Chart.js Axes Chart.js Axes provides the necessary context, labels, and scaling to make the charts more informative so that they can look visually appealing. Axes can be applied on various types of charts like lines, bars, radar, etc. Types of AxesAxes: It is an integral part of Chart.js and it is used to determi
4 min read
Graphical Data Analysis in R Graphical Data Analysis (GDA) is a powerful tool that helps us to visualize and explore complex data sets. R is a popular programming language for GDA as it has a wide range of built-in functions for producing high-quality visualizations. In this article, we will explore some of the most commonly us
7 min read
Advanced Excel Charts Chart formatting in Excel is used to easily add a certain set of styles such as colors, patterns for data representation, legends, axis titles, chart titles, etc. We add these formatting styles to enhance the visualization of charts and also, it will help for data analysis. One of the best ways to f
5 min read
How to Create Advanced Charts and Graphs in Excel? Charts, graphics, and images are excellent ways to visualize and convey data, and Excel does the same for us by generating charts automatically. We might occasionally want to go beyond the basic charts that Excel generates for us. Let's learn about advanced charts and graphs used in excel, Advanced
10 min read
Exploratory Graphs for EDA in R Exploratory Data Analysis (EDA) is a crucial step in the data science process that helps to understand the underlying structure of a data set. One of the most efficient ways to perform EDA is through the use of graphical representations of the data. Graphs can reveal patterns, outliers, and relation
6 min read