Strip Charts in R

 

Strip Charts in R

Introduction

A strip chart (also called a dot plot) is a simple graphical technique used to display individual observations of a dataset. Each data value is represented by a dot placed along an axis.

Strip charts are particularly useful for:

  • Small datasets.
  • Visualizing the distribution of data.
  • Comparing groups.
  • Detecting clusters and outliers.
  • Displaying individual observations without grouping them into bins.

Unlike histograms, strip charts display every data point, making them ideal when the number of observations is relatively small.


Syntax

stripchart(x,
method,
pch,
col,
main,
xlab,
ylab,
vertical)

where

  • x : vector or formula.
  • method : arrangement of points.
  • pch : plotting symbol.
  • col : color.
  • main : title.
  • xlab : x-axis label.
  • ylab : y-axis label.
  • vertical : vertical or horizontal display.

Example 1: Simple Strip Chart

Suppose marks of students are

marks <- c(45,50,55,60,65,70,75,80,85,90)

stripchart(marks)

Output:

Dots are plotted horizontally.




Example 2: Add Title and Labels

stripchart(marks,
main="Student Marks",
xlab="Marks")



Example 3: Change Plotting Symbol

stripchart(marks,
pch=19)

Common Values of pch

pchSymbol
1Circle
2Triangle
3Plus
15Square
16Filled Circle
17Filled Triangle
18Diamond
19Solid Circle

Example:

stripchart(marks,
pch=18)

Example 4: Change Color

stripchart(marks,
pch=19,
col="blue")




Example 5: Vertical Strip Chart

stripchart(marks,
vertical=TRUE,
pch=19,
col="red")

This displays the data vertically.



Example 6: Stack Method

Suppose data contain repeated values:

marks <- c(60,65,65,70,70,70,75,80,80,85)

stripchart(marks,
method="stack",
pch=19,
col="blue")

Here identical values are stacked.




Example 7: Jitter Method

stripchart(marks,
method="jitter",
pch=19,
col="green")

The points are slightly displaced to avoid overlap.




Example 8: Overplot Method

stripchart(marks,
method="overplot",
pch=19)

Repeated values overlap.




Example 9: Student Heights

height <- c(150,155,160,162,165,
170,172,175,178,180)

stripchart(height,
pch=16,
col="purple",
main="Student Heights",
xlab="Height (cm)")



Example 10: Comparing Two Groups

male <- c(165,170,172,175,180)

female <- c(155,160,162,165,168)

stripchart(list(Male=male,
Female=female),
pch=19,
col=c("blue","red"),
method="jitter")

This creates two strip charts side by side.




Example 11: Using Formula Interface

marks <- c(80,85,75,90,70,
88,95,78,65,72)

gender <- factor(c("Male","Male","Male","Male","Male",
"Female","Female","Female","Female","Female"))

stripchart(marks~gender,
method="jitter",
pch=19,
col=c("blue","pink"))

The notation

marks ~ gender

means:

Plot marks grouped by gender.

 



Example 12: Using Data Frames

student <- data.frame(
Gender=c("Male","Male","Female",
"Female","Male"),
Marks=c(80,85,90,75,88)
)

stripchart(Marks~Gender,
data=student,
pch=19,
method="jitter",
col=c("blue","red"))




Example 13: Multiple Departments

cse <- c(80,85,90,88,92)
ece <- c(70,75,78,82,85)
me <- c(65,68,72,76,80)

stripchart(list(CSE=cse,
ECE=ece,
ME=me),
method="jitter",
pch=19,
col=rainbow(3))




Example 14: Strip Chart with Box Plot

marks <- c(45,50,55,60,65,70,75,80,85,90)

boxplot(marks,
horizontal=TRUE)

stripchart(marks,
method="jitter",
pch=19,
col="red",
add=TRUE)

This overlays individual observations on the box plot.




Example 15: Random Data

x <- rnorm(100)

stripchart(x,
method="jitter",
pch=19,
col="green")




Methods Available

MethodDescription
"overplot"        Points overlap
"stack"        Repeated values stacked
"jitter"        Points randomly displaced

Important Parameters

ParameterPurpose
method    Arrangement of points
pch    Plotting symbol
col    Color
main    Title
xlab    X-axis label
ylab    Y-axis label
vertical    Vertical plot
add    Add to existing graph

Applications

  • Displaying individual observations.
  • Comparing groups.
  • Detecting outliers.
  • Supplementing box plots.
  • Small sample data analysis.
  • Exploratory Data Analysis (EDA).

Difference Between Strip Chart and Histogram

Strip ChartHistogram
Shows every observation    Shows frequencies
Suitable for small datasets    Suitable for large datasets
Uses dots    Uses bars
No binning required    Requires bins
Created using stripchart()    Created using hist()

Difference Between Strip Chart and Box Plot

Strip ChartBox Plot
Shows all observations    Shows summary statistics
Individual values visible    Values summarized by quartiles
Better for small datasets    Better for comparing distributions
Uses dots    Uses box and whiskers

Summary of Useful Functions

FunctionPurpose
stripchart()        Create strip chart
boxplot()        Create box plot
jitter()        Random displacement
list()        Multiple groups
factor()        Grouping variable
rainbow()        Generate colors

Conclusion

A strip chart is a one-dimensional scatter plot used to display individual data values. It is especially useful for small datasets and for visualizing the distribution and spread of observations. In R, the stripchart() function provides various methods such as overplot, stack, and jitter, making it an effective tool for exploratory data analysis and comparison of groups.

Comments

Popular posts from this blog

Statistical Methods Lab ( R Language) PCCBL308 Semester 3 KTU BTech CB and CU 2024 Scheme - Dr Binu V P

Programs in R - using control statements - Assignment 2

Basic R Programs to Try - Assignment 1