How to create a histogram using plotly in R

This recipe helps you create a histogram using plotly in R

Recipe Objective

How to create a histogram using Plotly in R?

Histogram plots a graph of continuous value variable with their corresponding frequencies. The data is plotted as bars of different heights. The difference between bar plot and histogram is that the bar charts are plotted for discrete data, whereas a histogram is plotted for continuous data. A histogram provides a visual representation of the distribution of data, which helps us to know whether the data is symmetric or skewed in nature. It also displays if there are any out-liners in my dataset. Plotly is an interface to an open source JavaScript charting library Plot_ly () function is used to plot histogram using plotly in R. This recipe demonstrates an example of histogram.

Step 1 - Install the necessary package and library

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

Step 2 - Define a Vector

data <- c(128,4,96,8,10,120,150,116,108,200,120,24,26,28,30,32,34,36,138,40,82,44,66,48,150)

Step 3 - Plot a histogram

Syntax for histogram using plotly - plot_ly(x,type) where, x - input data type - type of graph

figure <- plot_ly(x=data, type = "histogram") figure {"mode":"full","isActive":false}

What Users are saying..

profile image

Ameeruddin Mohammed

ETL (Abintio) developer at IBM
linkedin profile url

I come from a background in Marketing and Analytics and when I developed an interest in Machine Learning algorithms, I did multiple in-class courses from reputed institutions though I got good... Read More

Relevant Projects

Credit Card Default Prediction using Machine learning techniques
In this data science project, you will predict borrowers chance of defaulting on credit loans by building a credit score prediction model.

Build an AI Chatbot from Scratch using Keras Sequential Model
In this NLP Project, you will learn how to build an AI Chatbot from Scratch using Keras Sequential Model.

Time Series Analysis with Facebook Prophet Python and Cesium
Time Series Analysis Project - Use the Facebook Prophet and Cesium Open Source Library for Time Series Forecasting in Python

BigMart Sales Prediction ML Project in Python
The goal of the BigMart Sales Prediction ML project is to build and evaluate different predictive models and determine the sales of each product at a store.

Image Classification Model using Transfer Learning in PyTorch
In this PyTorch Project, you will build an image classification model in PyTorch using the ResNet pre-trained model.

GCP MLOps Project to Deploy ARIMA Model using uWSGI Flask
Build an end-to-end MLOps Pipeline to deploy a Time Series ARIMA Model on GCP using uWSGI and Flask

Time Series Classification Project for Elevator Failure Prediction
In this Time Series Project, you will predict the failure of elevators using IoT sensor data as a time series classification machine learning problem.

ML Model Deployment on AWS for Customer Churn Prediction
MLOps Project-Deploy Machine Learning Model to Production Python on AWS for Customer Churn Prediction

Personalized Medicine: Redefining Cancer Treatment
In this Personalized Medicine Machine Learning Project you will learn to classify genetic mutations on the basis of medical literature into 9 classes.

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.