Solutions Touch
← Back to all blogs

August 19, 2019

R Bar Plot

By Rahul Swami

R   Bar Plot

you will learn to create bar plot for compare data visually.

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.

barplot(marks)

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)
barplot(marks,
main = "maximum marks in subject",
xlab = "progress",
ylab = "subjects",
names.arg = c("Mar", "Hin", "Phy", "Chem", "Bio", "Math"),
col = "red",
horiz = TRUE)

bar chart in r ggplot2 bar plot r grouped bar plot r ggplot2 stacked bar chart in r ggplot2 stacked bar plot r r bar plot two data sets r barplot two variables bar plot of means in r bar plot in r r bar chart barplot in r barplot in r programming color bar plot in r color bar c