• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Data Viz with Python and R

Learn to Make Plots in Python and R

  • Home
  • Seaborn
  • Matplotlib
  • ggplot2
  • Altair
  • About
    • Privacy Policy
  • Visualizing Activation Functions in Neural Networks
  • Confusion Matrix Calculator
  • Visualizing Dropout Rate in Neural Network
  • Visualizing Loss Functions in Neural Networks
  • Show Search
Hide Search

Scatter Plot with Transparent Points Using ggplot2 in R

datavizpyr · December 11, 2019 ·

Last updated on August 15, 2025

While scatter plots are ideal for visualizing the relationship between two quantitative variables, their effectiveness diminishes with large datasets due to overplotting. This issue occurs when numerous data points are plotted on top of each other, hiding the true density of the data. To solve this, we can make the points transparent. In this tutorial, we’ll use the alpha argument in ggplot2 to control the transparency and create a more insightful plot.

Let us load ggplot2 to make the scatter plot with transparent data points.
library(ggplot2)
Let us make a data frame with two quantitative variables. We generate these variables using random numbers from normal/gaussian distribution.
set.seed(42)
x <- rnorm(2000, mean=15, sd=20)
y <- x+ rnorm(2000, mean=2, sd=30)
df <- data.frame(x=x, y=y)
Let us make a simple scatter plot to illustrate the problem of overplotting
df %>% 
  ggplot(aes(x=x, y=y)) + geom_point()
Scatter plot with overplotting of data points
We can see that many points overlap on each other and make it difficult to see most of the data points. Let us set transparency level to avoid over plotting
df %>%  
 ggplot(aes(x=x,y=y)) + geom_point(alpha=0.3)
Scatter Plot with Transparent Data Points
Scatter Plot with Transparent Data Points

Explore the Complete ggplot2 Guide

35+ tutorials with code: scatterplots, boxplots, themes, annotations, facets, and more—tested and beginner-friendly.

Visit the ggplot2 Hub → No fluff—just code and visuals.

Related posts:

Simple Scatter Plot in R with ggplot2 Customizing Labels on Bars in Side by side Stacked BarplotHow To Add Labels to Grouped Barplot with Bars Side-By-Side in R? Visualizing Missing Data with Barplot in R ggplot2Visualizing Missing Data with Barplot in R Annotate Clusters with Ellipse with Labels ggforceHow To Annotate Clusters with Circle/Ellipse by a Variable in R

Filed Under: ggplot2, R, Scatter Plot ggplot2 Tagged With: ggplot2, R

Primary Sidebar

Python & R Viz Hubs

  • Seaborn Guide & Cookbook
  • ggplot2 Guide & Cookbook
  • Matplotlib Guide & Cookbook
  • Confusion Matrix Calculator
  • Visualizing Activation Functions
  • Visualizing Dropout
  • Visualizing Loss Functions

Buy Me a Coffee

Copyright © 2026 · Daily Dish Pro on Genesis Framework · WordPress · Log in

Go to mobile version