Submitted by : Rahul Swami
Language : R
Downloader: 1
Posted on : 31-05-2019 11:56:53a

Download Code

The Bar Chart in R Programming is useful to compare the data. Bar plots can be created using the barplot() function. R can draw Horizontal and vertical bars in the bar chart.

Create Simple Bar Chart

we have a vector of maximum marks of six subjects as follows.

marks <- c(23, 12, 43, 18, 20, 30)

we can make bar plot using this data.


xlab - label for x axis.

ylab - label for y axis.

main - title of the bar chart.

col - give colors to the bars.

names.arg - give name for each bar.

horiz = TRUE - plot bar horizontally.

marks <- c(23, 12, 43, 18, 20, 30)
main = "maximum marks in subject",
xlab = "progress",
ylab = "subjects",
names.arg = c("Mar", "Hin", "Phy", "Chem", "Bio", "Math"),
col = "red",
horiz = TRUE)