- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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 a bar chart using ggplot2 with dots drawn at the center of top edge of the bars in R?
Aesthetics is one of the most important aspect of a chart, hence we should try to use the best possible aesthetic properties in a plot. In a bar chart, we can represent the center of bars in many ways and one such way is using dots at the center of the top edge of the bars. We can use geom_point function by defining colour argument to put points at the center of top edge of the bars in a bar chart created by using ggplot2.
Example
Consider the below data frame:
> freq<-c(212,220,218) > df<-data.frame(x,freq) > df
Output
x freq 1 Mango 212 2 Guava 220 3 Pomegranate 218
Loading ggplot2 package and creating bar chart for x:
> library(ggplot2) > ggplot(df,aes(x,freq))+geom_bar(stat="identity")
Output:
Creating bar chart with dots drawn at the center of top edge of the bars:
Example
> ggplot(df,aes(x,freq))+geom_bar(stat="identity")+geom_point(colour="blue",size=5)
Output:
- Related Articles
- How to create a horizontal bar chart using ggplot2 with labels at inside end of the bars in R?
- How to create a bar plot in R with label of bars on top of the bars using ggplot2?
- How to create plotly bar chart with values on top of bars in R?
- How to create bar chart using ggplot2 with chart sub-title in R?
- How to create the bar chart with ggplot2 using color brewer in R?
- How to create a line chart using ggplot2 that touches the edge in R?
- How to create a stacked bar plot with vertical bars in R using ggplot2?
- How to create bar plot of means with error bars of standard deviations using ggplot2 in R?
- How to reverse the bars of a bar plot a using ggplot2 in R?
- How to create a bar chart using ggplot2 with facets that are in the order of the data in R?
- How to change the color of bars of a bar plot using ggplot2 in R?
- How to create a histogram with dots instead of bars in base R?
- How to create a bar chart for single vector using ggplot2 in R?
- How to increase the space between bars of a bar plot using ggplot2 in R?
- How to change the order of bars in bar chart in R?

Advertisements