- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to create bar chart using ggplot2 with chart sub-title in R?
There are different ways to express any chart. The more information we can provide in a chart, the better it is because a picture says thousand words. Since nobody likes to read a long-reports, we should have better reporting of charts. Therefore, we can add a chart title as well as chart sub-title in ggplot2 to help the readers.
Example
Consider the below data −
> set.seed(1) > x<-rpois(20,5) > table(x) x 2 3 4 5 6 7 8 9 11 1 3 4 2 4 2 2 1 1 > df<-data.frame(x)
Loading ggplot2 package −
> library(ggplot2)
Creating a simple bar chart −
> ggplot(df,aes(x))+ + geom_bar()
Output
Creating a bar chart with title and sub-title −
> ggplot(df,aes(x))+ + geom_bar()+ + ggtitle(expression(atop("Class Group", atop(italic("Frequency Bar Chart")))))
Output
- Related Articles
- How to create the bar chart with ggplot2 using color brewer in R?
- How to create a bar chart for single vector using ggplot2 in R?
- Create stacked bar chart with percentages on Y-axis using ggplot2 in R.
- How to set the chart title at the bottom using ggplot2 in R?
- How to create a bar chart using plotly in R?
- How to create stacked bar chart using ggvis in R?
- How to create line chart using ggplot2 in R with 3-sigma limits?
- How to create a point chart with empty points using ggplot2 in R?
- How to create a line chart using ggplot2 with larger width in R?
- How to create horizontal stacked bar chart using ggvis in R?
- How to create a horizontal bar chart using ggplot2 with labels at inside end of the bars in R?
- How to create plotly bar chart with negative values in R?
- How to create a line chart using ggplot2 with a vertical line in R?
- How to create a bar chart using ggplot2 with facets that are in the order of the data in R?
- How to create varying width bar chart using barplot function in R?

Advertisements