Open In App

Strip Plots Using Lattice Package in R

Last Updated : 30 Dec, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

 In general, Strip Plots are used to plot univariate data. It’s a 2D plot where on X-Axis the response variables are plotted. 

These are alternatives to the histogram or density plot. It is typically used to plot small data sets so here we will be using the iris dataset to implement it.

In, R Programming, the Strip Plots can be implemented using the stripplot() function which is present in the lattice package.

Syntax: stripplot(formula,data,jitter,factor,xlab,ylab,main)

where,

  • data – data frame that needs to be considered to plot
  •  jitter – used to specify whether the values should be jittered or not
  • factor – used to specify the amount of jitter
  • xlab – used to specify the X-axis label
  • main – used to specify the title of the plot

Let’s see the code for Simple Strip Chart. In this, we will be using the iris dataset and plotting the sepal length using stripplot().

R




# Install the required package
install.packages("lattice")
# Load the installed package
library(lattice)
  
# Load the default dataset(iris) into current working environment 
data(iris)
  
# Plotting the Simple Strip plot using striplot()
lattice::stripplot(~Sepal.Length, data=iris,
                   jitter=TRUE, xlab="Sepal Length",
                   main="Simple Strip Plot of iris Dataset")


Output:

Strip plot

 

We can also plot the Partitioned Strip Plot for each category. Here we are categorizing according to Species column. The code is given below.

R




# Install the required package
install.packages("lattice")
# Load the installed package
library(lattice)
  
# Load the default dataset(iris) into current working environment 
data(iris)
  
# Plotting the Partitioned Strip plot using striplot()
lattice::stripplot(~Sepal.Length|Species, data=iris,
                   jitter=TRUE, layout=c(1,3),
                   xlab="Sepal Length")


Output:

Partitioned stripplot

 

We can also customize the plot using col parameter. We can add different colors to the plot.

R




# Install the required package
install.packages("lattice")
# Load the installed package
library(lattice)
  
# Load the default dataset(iris) into current working environment 
data(iris)
  
# Plotting the Customized Strip plot using striplot()
lattice::stripplot(~Sepal.Length|Species, data=iris,
                   jitter=TRUE,layout=c(1,3), xlab="Sepal Length",
                   main="Customized Strip Plot of iris Dataset",
                   col=c("red","blue","green"))


Output:

Customized

 



Similar Reads

Density Plots Using Lattice Package in R
The density plots are mainly used to visualize the distribution of continuous numeric variables. The densityplot() uses kernel density probability estimate to calculate the density probability of numeric variables. In R Programming, the density plot can be plotted using the densityplot() function which is present in the lattice package. Syntax: den
2 min read
Draw Multiple lattice Plots in One Window in R
In this article, we will discuss how to draw multiple lattice plots in One window. Module Usedlattice: The lattice package uses grid package to provide better relationships between the data. It is an add-on package for the implementation of Trellis graphics (graphics that shows relationships between variables conditioned together).gridExtra: This p
2 min read
Axes and Scales in Lattice Plots in R
In R Programming Language, lattice graphics are a powerful method for displaying data. They offer a versatile and dependable framework for making many other types of plots, such as scatterplots, bar charts, and more. Understanding how to adjust and modify the axes and scales is a crucial component in producing successful lattice graphs. We will exa
4 min read
How to create a scatter plot using lattice package in R?
In this article, we will discuss how to create the scatter plots using lattice package in R programming language. In R programming, the Lattice package is a data visualization library that consists of various functions to plot different kinds of plots. Using the lattice library we can able to plot various kinds of plots like scatter plot, Box plots
2 min read
How to create a boxplots using lattice package in R?
In this article, we will discuss how to create the boxplots using lattice package in R Programming language. In R programming, Lattice package is a data visualization library and consists of various functions to plot different kind of plots. Using lattice library we can able to plot different plots like scatter plot, Box plots, Histograms, 3D scatt
2 min read
Histograms in the Lattice Package
For making trellis or tiny multiple plots, a style of visualization that displays several versions of a plot for subsets of the data, the Lattice package in R is a potent tool. Lattice's histogram() function can be used to generate histograms for continuous variables and includes a number of useful features. Grouping: Using the group argument of th
8 min read
Multiple Line Plots or Time Series Plots with ggplot2 in R
In this article, we will discuss how to plot Multiple Line Plots or Time Series Plots with the ggplot2 package in the R Programming Language. We can create a line plot using the geom_line() function of the ggplot2 package. Syntax: ggplot( df, aes( x, y ) ) + geom_line() where, df: determines the dataframe usedx and y: determines the axis variables
2 min read
Draw Composition of Plots Using the patchwork Package in R
In this article, we will discuss how to draw a composition of plots using the patchwork package in R programming language. The patchwork package makes it easier to plot different ggplots in a single graph. We will require both ggplot2 packages for plotting our data and the patchwork package to combine the different ggplots. Let us first draw all th
4 min read
How to create 3D Plots and Animations in R using rgl Package
The R programming language provides a powerful set of tools and packages for creating interactive 3D plots and animations. One such package is RGL. In this article, let us learn How to create 3D plots and animations using the RGL package. Create 3D Plots and Animation in R using RGL Package The RGL package in R provides an interface to the OpenGL g
5 min read
Labeling line plots with geomtextpath package in R
In this article, we are going to see how to use direct Labeling on line plots with geomtextpath Package in R Programming Language. Geomtextpath is used to customize the labeling and using geomtextpath graph text follows any path, and it will remain correctly spaced and angled, even if you change the size and aspect ratio of your plotting device. In
2 min read