How to plot strip chart in R?

How to plot strip chart in R?

How to plot strip chart in R?

This recipe helps you plot strip chart in R


Recipe Objective

A strip chart is a special form of chart which showcases raw numerical data over a period of time along a single strip. Just as Boxplots, they are mainly used for visualising the distribution of the dataset. The only difference between the two charts is that strip chart is mainly used when sample sizes are small and you can see the individual points. They are also known as one-dimensional scatter plots.

This recipe demonstartes how to create a strip chart in R.

Step 1: Loading library and dataset

Dataset description: It is the basic data about the customers going to the supermarket mall. The variable that we interested in is Annual.Income which is in 1000s

# Data manipulation package library(tidyverse) ​ # reading a dataset customer_seg = read.csv('Mall_Customers.csv') ​ glimpse(customer_seg)
Observations: 200
Variables: 5
$ CustomerID              1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1...
$ Gender                  Male, Male, Female, Female, Female, Female, ...
$ Age                     19, 21, 20, 23, 31, 22, 35, 23, 64, 30, 67, ...
$ Annual.Income..k..      15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 19, ...
$ Spending.Score..1.100.  39, 81, 6, 77, 40, 76, 6, 94, 3, 72, 14, 99,...

Step 2. Strip Chart

We will display a strip chart of Annual Income variable using stripchart() built-in function

Syntax: stripchart(x, main = , xlab =, method= , col = , pch =)


  1. x = a numeric vector that needs to be plotted;
  2. main = gives the title of the chart;
  3. xlab = gives the label of the x-axis;
  4. method = This gives a method to be used to separate the overlapping points;
  5. col = we can input the required colour to the points through this arguement.
  6. pch = Gives the shape of the points.
# method = jitter means that the points will be jittered around instead of bein overlap stripchart(customer_seg$Annual.Income..k.., main = "Annual Income Distribution", xlab = "Annual Income (in 1000s)", method = "jitter", col = "red", pch = 1)

Relevant Projects

Zillow’s Home Value Prediction (Zestimate)
Data Science Project in R -Build a machine learning algorithm to predict the future sale prices of homes.

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.

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.

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.

Learn to prepare data for your next machine learning project
Text data requires special preparation before you can start using it for any machine learning project.In this ML project, you will learn about applying Machine Learning models to create classifiers and learn how to make sense of textual data.

Machine Learning or Predictive Models in IoT - Energy Prediction Use Case
In this machine learning and IoT project, we are going to test out the experimental data using various predictive models and train the models and break the energy usage.

Ecommerce product reviews - Pairwise ranking and sentiment analysis
This project analyzes a dataset containing ecommerce product reviews. The goal is to use machine learning models to perform sentiment analysis on product reviews and rank them based on relevance. Reviews play a key role in product recommendation systems.

Predict Employee Computer Access Needs in Python
Data Science Project in Python- Given his or her job role, predict employee access needs using amazon employee database.

Data Science Project - Instacart Market Basket Analysis
Data Science Project - Build a recommendation engine which will predict the products to be purchased by an Instacart consumer again.

Data Science Project in Python on BigMart Sales Prediction
The goal of this data science project is to build a predictive model and find out the sales of each product at a given Big Mart store.