- 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 scatterplot in R using ggplot2 with transparency of points?
A scatterplot is used to observe the relationship between two continuous variables. If the sample size is large then the points on the plot lie on each other and does not look appealing. Also, the interpretation of such type of scatterplots is not an easy task, therefore, we can increase the transparency of points on the plot to make it more appealing. We can do this by using alpha argument in geom_point of ggplot2.
Example
Consider the below data frame −
> set.seed(123) > x<-rnorm(5000) > y<-rnorm(5000,0.5) > df<-data.frame(x,y) > library(ggplot2) > ggplot(df,aes(x,y))+geom_point()
Output
> ggplot(df,aes(x,y))+geom_point(alpha=0.10)
Output
> ggplot(df,aes(x,y))+geom_point(alpha=0.05)
Output
- Related Articles
- How to create a scatterplot with dark points using ggplot2 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 create a scatterplot with two legends 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 create scatterplot with intercept equals to 1 using ggplot2 in R?
- How to change the color of points in a scatterplot using ggplot2 in R?
- How to color scatterplot points based on a threshold using ggplot2 in R?
- How to create scatterplot using ggplot2 without grey background in R?
- How to create a scatterplot with white background and no gridlines using ggplot2 in R?
- How to create scatterplot for categories with grey color palette 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 with legend position inside the plot area using ggplot2?
- How to change the border color of points in a scatterplot created with ggplot2 in R?
- How to create a point chart with empty points using ggplot2 in R?

Advertisements