• 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
  • Python Viz
  • Seaborn
  • Altair
  • R Viz
  • ggplot2
  • About
    • Privacy Policy
  • Show Search
Hide Search

Simple Scatter Plot in R with ggplot2

datavizpyr · December 11, 2019 ·

Scatter plot is a great data visualization tool to visualize relationship between two quantitative variables. We will see an example to make a simple scatter plot in R with ggplot2. Let us first load the ggplot2 package.
library(tidyverse)
Let us create a data set and store it in a data frame.
set.seed(42)
x <- rnorm(100, mean=5, sd=20)
y <- x + rnorm(100, mean=1, sd=20)
df <- data.frame(x=x, y=y)
Let us use the above dataframe to make scatter plot with ggplot2 in R. In ggplot2, geom_point() function helps us make scatter plot. After defining the aesthetics for ggpot2, we can add geom_point() to make scatter plot.
df %>%
   ggplot(aes(x=x,y=y)) + geom_point()
Here we have the simple scatter plot that we just made.
Simple Scatter Plot in R with ggplot2
Are you making a scatter plot with a lots of data points? Then your scatter plot might suffer from overplotting. Check out this post Scatter plots with transparent data points to make a better scatter plot without overplotting.

Related posts:

Scatter Plot with Transparent Data PointsScatter Plot with Transparent Points Using ggplot2 in R Scatter Plot R: Fill color by variableHow To Color Scatter Plot by Variable 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

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

Primary Sidebar

Tags

Altair barplot Boxplot boxplot python boxplot with jiitered text labels Bubble Plot Color Palette Countplot Density Plot Facet Plot gganimate ggplot2 ggplot2 Boxplot ggplot2 error ggplot boxplot ggridges ggtext element_markdown() Grouped Barplot R heatmap heatmaps Histogram Histograms Horizontal boxplot Python lollipop plot Maps Matplotlib Pandas patchwork pheatmap Pyhon Python R RColorBrewer reorder boxplot ggplot Ridgeline plot Scatter Plot Scatter Plot Altair Seaborn Seaborn Boxplot Stock Price Over Time Stripplot UpSetR Violinplot Violin Plot World Map ggplot2

Buy Me a Coffee

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

Go to mobile version