
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Create Scatterplot in R using ggplot2 with Transparency
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
Advertisements