How to create bubble chart in R?

This recipe helps you create bubble chart in R

Recipe Objective

How to create a bubble chart in R? A bubble chart is a variant of the scatter plot where we compare the relationship between two continuous variables with one additional variable of size, that is the size of each data point. A bubble chart is a two-dimensional data visualization chart that displays data in the form of circles (bubbles). A bubble chart takes three variables of the data, namely the size of the bubble, horizontal and vertical location of the data points. This recipe demonstrates an example of a bubble chart using ggplot.

Step 1 - Import necessary libraries

library("ggplot2") library("dplyr")

Step 1 - Define a dataframe

**Syntax for bubble plot is-ggplot (data, aes (x,y, size))+geom_point ()** where, data — the required data to plot bubble chart aes (x=data,y=data,size)) — the aes function — creates bubble from data to geom geom_point — the geometric object to be drawn — bubble

# define two variables data = data.frame (x_data =c(2,4,6,8,10,12), y_data = c(10,20,30,40,50,60)) print(data)

Step 2 - Plot a bubble chart

ggplot(data, aes(x=x_data, y=y_data, size = x_data,col=x_data)) +geom_point() # the size of bubble differs as value increases the size of the bubbles/circles increases.

What Users are saying..

profile image

Abhinav Agarwal

Graduate Student at Northwestern University
linkedin profile url

I come from Northwestern University, which is ranked 9th in the US. Although the high-quality academics at school taught me all the basics I needed, obtaining practical experience was a challenge.... Read More

Relevant Projects

Learn to Build a Siamese Neural Network for Image Similarity
In this Deep Learning Project, you will learn how to build a siamese neural network with Keras and Tensorflow for Image Similarity.

AWS MLOps Project to Deploy Multiple Linear Regression Model
Build and Deploy a Multiple Linear Regression Model in Python on AWS

Deploying Machine Learning Models with Flask for Beginners
In this MLOps on GCP project you will learn to deploy a sales forecasting ML Model using Flask.

Recommender System Machine Learning Project for Beginners-3
Content Based Recommender System Project - Building a Content-Based Product Recommender App with Streamlit

Build CNN for Image Colorization using Deep Transfer Learning
Image Processing Project -Train a model for colorization to make grayscale images colorful using convolutional autoencoders.

AWS Project to Build and Deploy LSTM Model with Sagemaker
In this AWS Sagemaker Project, you will learn to build a LSTM model on Sagemaker for sales forecasting while analyzing the impact of weather conditions on Sales.

Deep Learning Project for Beginners with Source Code Part 1
Learn to implement deep neural networks in Python .

Build a Multi Touch Attribution Machine Learning Model in Python
Identifying the ROI on marketing campaigns is an essential KPI for any business. In this ML project, you will learn to build a Multi Touch Attribution Model in Python to identify the ROI of various marketing efforts and their impact on conversions or sales..

Recommender System Machine Learning Project for Beginners-2
Recommender System Machine Learning Project for Beginners Part 2- Learn how to build a recommender system for market basket analysis using association rule mining.

Build a Customer Churn Prediction Model using Decision Trees
Develop a customer churn prediction model using decision tree machine learning algorithms and data science on streaming service data.