- Trending Categories
- Data Structure
- Operating System
- C Programming
- 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 increase the size of points on a scatterplot if the points are drawn based on another sequence using ggplot2 in R?
When we draw a scatterplot using ggplot2 with points based on a sequence of values then the size of the points might be very small for the small values. As a result, it becomes a little difficult to view the points. Therefore, we might want to increase the size of those points. It can be done by using scale_size_continuous function in which we can set a range for the points size.
Consider the below data frame −
x<-rnorm(10,1) y<-rnorm(10,2) Pair<-1:10 df<-data.frame(x,y,Pair) df
x y Pair 1 0.2722750 0.7855144 1 2 0.6708724 2.8385502 2 3 1.6939261 1.7415868 3 4 0.5773440 2.1596557 4 5 0.1965571 0.7356820 5 6 0.3368027 1.4774414 6 7 0.8248820 2.8211750 7 8 -0.3364834 2.5258274 8 9 -0.3229903 1.1579749 9 10 -1.1594988 1.0636472 10
Loading ggplot2 package and creating a scatterplot with points size based on Pair column −
Creating the scatterplot with a range of point size −
ggplot(df,aes(x,y,size=Pair))+geom_point()+scale_size_continuous(range = c(2,5))
- How to color scatterplot points based on a threshold using ggplot2 in R?
- How to create a scatterplot using ggplot2 with different shape and color of points based on a variable in R?
- How to change the color of points in a scatterplot using ggplot2 in R?
- How to change the default type of points for scatterplot using ggplot2 in R?
- How to create a scatterplot in R using ggplot2 with transparency of points?
- How to create a scatterplot with dark points using ggplot2 in R?
- How to change the color of points for ggplot2 scatterplot using color brewer in R?
- How to create a scatterplot in R using ggplot2 with different designs of points?
- How to create a scatterplot with low intensity of points using ggplot2 in R?
- How to join points on a scatterplot with smooth lines in R using plot function?
- How to change the border color of points in a scatterplot created with ggplot2 in R?
- How to create a scatterplot in base R with points depending on categorical column?
- How to join the points of a point chart if X-axis values are categorical in R using ggplot2?
- How to create a scatterplot with colors of the group of points in R?
- How to increase the X-axis labels font size using ggplot2 in R?