- 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 dot plot using ggplot2 in R?
A dot plot is a type of histogram that display dots instead of bars and it is created for small data sets. In ggplot2, we have geom_dotplot function to create the dot plot but we have to pass the correct binwidth which is an argument of the geom_dotplot, so that we don’t get the warning saying “Warning: Ignoring unknown parameters: bins `stat_bindot()` using `bins = 30`. Pick better value with `binwidth`.”
Example
Consider the below data frame −
> x<-rnorm(100) > df1<-data.frame(x)
Loading ggplot2 package −
> library(ggplot2)
Creating the dot plot of x −
> ggplot(df1,aes(x))+geom_dotplot(binwidth=0.2)
Output
Let’s have a look at one more example −
> y<-sample(1:10,100,replace=TRUE) > df2<-data.frame(y) > ggplot(df2,aes(y))+geom_dotplot(binwidth=0.2)
Output
- Related Articles
- How to create transparent bar plot using ggplot2 in R?
- How to create an empty plot using ggplot2 in R?
- How to create a bar plot with ggplot2 using stat_summary in R?
- How to create stacked plot with density using ggplot2 in R?
- How to create dotted vertical lines in a plot using ggplot2 in R?
- How to create a plot title with unicode characters using ggplot2 in R?
- How to create bar plot with log values using ggplot2 in R?
- How to create bar plot with gradient colors using ggplot2 in R?
- How to create a stacked bar plot with vertical bars in R using ggplot2?
- How to create the stacked bar plot using ggplot2 in R with labels on the plot?
- How to create a bar plot using ggplot2 with percentage on Y-axis in R?
- How to create facetted plot with facets in horizontal direction using ggplot2 in R?
- Create multiple regression lines in a single plot using ggplot2 in R.
- How to create a scatterplot in R with legend position inside the plot area using ggplot2?
- How to create a bar plot using ggplot2 with one bar having black border in R?

Advertisements