R barplot() – Main Title

To set main title for Bar Plot drawn using barplot() function, pass the required title value for main parameter in the function call.

main parameter is optional and can accept a value to set the main title for bar plot.

If no value is specified for main parameter, then the bar plot would have no main title.

Examples

In the following program, we set main title for bar plot.

example.R

height <- c(2, 4, 7, 5)
barplot(height, main = "Bar Plot Sample Title")

Output

R barplot() - Main Title
ADVERTISEMENT

Conclusion

In this R Tutorial, we learned how to set main title Bar Plot drawn using R barplot() function, with the help of examples.