How to create scatter plot on maps in R using plotly

This recipe helps you create scatter plot on maps in R using plotly

Recipe Objective

How to create a scatter plot on maps in R using Plotly ?

Scatter plots are graphs that represent a relation between an independent variable (x) and a dependent variable (y). The plots represent data on a 2 dimensional plane, where dependent variable (y) is plotted on the Y-axis and an independent variable (x) is plotted on the X-axis. Scatter plots are used to explain the correlation between the two variables. There are mainly 3 cases in scatter plot correlation – - Positive correlation - Negative correlation - No correlation Scatter plots help us understand and visualize the data properly. This recipe demonstrates an example of scatter plots using Plotly.

Step 1 - Install the necessary library

install.packages("plotly") library(plotly)

Step 2 - Define the data points

df <- data.frame (x <- c(2,3,8,9,4,6,9,7,6,9), y <- c(3,9,5,6,8,6,5,8,9,3))

Step 3 - Plot a scatter plot

Syntax - plotly(data,x,y,type) where, data - input dataframe x - values on x axis y - values on y axis type - scatter

figure <- plot_ly(data = df, x = x, y =y, type = "scatter", mode = "markers") figure {"mode":"full","isActive":false}

What Users are saying..

profile image

Ed Godalle

Director Data Analytics at EY / EY Tech
linkedin profile url

I am the Director of Data Analytics with over 10+ years of IT experience. I have a background in SQL, Python, and Big Data working with Accenture, IBM, and Infosys. I am looking to enhance my skills... Read More

Relevant Projects

Learn to Build an End-to-End Machine Learning Pipeline - Part 1
In this Machine Learning Project, you will learn how to build an end-to-end machine learning pipeline for predicting truck delays, addressing a major challenge in the logistics industry.

NLP and Deep Learning For Fake News Classification in Python
In this project you will use Python to implement various machine learning methods( RNN, LSTM, GRU) for fake news classification.

Build Portfolio Optimization Machine Learning Models in R
Machine Learning Project for Financial Risk Modelling and Portfolio Optimization with R- Build a machine learning model in R to develop a strategy for building a portfolio for maximized returns.

Azure Text Analytics for Medical Search Engine Deployment
Microsoft Azure Project - Use Azure text analytics cognitive service to deploy a machine learning model into Azure Databricks

Build a Multi ClassText Classification Model using Naive Bayes
Implement the Naive Bayes Algorithm to build a multi class text classification model in Python.

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.

Build CNN Image Classification Models for Real Time Prediction
Image Classification Project to build a CNN model in Python that can classify images into social security cards, driving licenses, and other key identity information.

Build a Churn Prediction Model using Ensemble Learning
Learn how to build ensemble machine learning models like Random Forest, Adaboost, and Gradient Boosting for Customer Churn Prediction using Python

Detectron2 Object Detection and Segmentation Example Python
Object Detection using Detectron2 - Build a Dectectron2 model to detect the zones and inhibitions in antibiogram images.

Build CI/CD Pipeline for Machine Learning Projects using Jenkins
In this project, you will learn how to create a CI/CD pipeline for a search engine application using Jenkins.