How to create bubble chart in R?

How to create bubble chart in R?

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.

Relevant Projects

Data Science Project-TalkingData AdTracking Fraud Detection
Machine Learning Project in R-Detect fraudulent click traffic for mobile app ads using R data science programming language.

Loan Eligibility Prediction using Gradient Boosting Classifier
This data science in python project predicts if a loan should be given to an applicant or not. We predict if the customer is eligible for loan based on several factors like credit score and past history.

Resume parsing with Machine learning - NLP with Python OCR and Spacy
In this machine learning resume parser example we use the popular Spacy NLP python library for OCR and text classification.

Natural language processing Chatbot application using NLTK for text classification
In this NLP AI application, we build the core conversational engine for a chatbot. We use the popular NLTK text classification library to achieve this.

Customer Churn Prediction Analysis using Ensemble Techniques
In this machine learning churn project, we implement a churn prediction model in python using ensemble techniques.

Human Activity Recognition Using Multiclass Classification in Python
In this human activity recognition project, we use multiclass classification machine learning techniques to analyse fitness dataset from a smartphone tracker.

Ensemble Machine Learning Project - All State Insurance Claims Severity Prediction
In this ensemble machine learning project, we will predict what kind of claims an insurance company will get. This is implemented in python using ensemble machine learning algorithms.

Credit Card Fraud Detection as a Classification Problem
In this data science project, we will predict the credit card fraud in the transactional dataset using some of the predictive models.

Walmart Sales Forecasting Data Science Project
Data Science Project in R-Predict the sales for each department using historical markdown data from the Walmart dataset containing data of 45 Walmart stores.

Deep Learning with Keras in R to Predict Customer Churn
In this deep learning project, we will predict customer churn using Artificial Neural Networks and learn how to model an ANN in R with the keras deep learning package.