Visualizing clusters using Hull Plots in ggplot2 using ggforce Last Updated : 28 Apr, 2025 Comments Improve Suggest changes Like Article Like Report The HULL Plots are also known as Grouped Scatter Plots because these plots are used to segregate the scatter plots based on clusters. The Hull plots are much more useful when one wants to visualize the clusters present among the data. The Hull plots in R can be plotted using the geom_mark_hull() function which is present in ggforce package. Syntax of geom_mark_hull() method Syntax: geom_mark_hull(mapping,data,concavity,radius,position) Where, mapping - set of aesthetic mappings created by aes() functiondata - The data frame to be displayedconcavity - used to set the concavity of thehullradius - used to specify corner radiusposition - used to adjust the position.Steps to Visualize Clusters using Hull Plot Step 1: First, we need to install the required packages (ggplot2, ggforce) and load them. R # Install Required Packages install.packages("ggplot2") install.packages("ggforce") # Load the installed Packages library(ggplot2) library(ggforce) Step 2: Next we need to plot the basic scatter plot using ggplot() function in the ggplot2 package. R # Load the default dataset (iris) data(iris) # Plotting the scatter plot using ggplot2 package fig1<-ggplot2::ggplot(aes (Sepal.Length,Sepal.Width), data=iris)+geom_point() print(fig1) Output: Step 3: Later we will add hulls(clusters) to that scatter plot using geom_mark_hull() function in ggforce package. R # Load the default dataset (iris) data(iris) # Plotting the scatter plot using ggplot2 package fig1<-ggplot2::ggplot(aes(Sepal.Length,Sepal.Width),data=iris)+geom_point() # Plotting the Hull Plot using ggforce package fig2 <- fig1 + ggforce::geom_mark_hull (aes(fill=Species,label=Species), concavity=2) print(fig2) Output: Step 4: We can also customize the Hull Plot in R using labs() function of ggforce package to add labels to the plot and using expand_limits() we can expand the limits of the x and y axes values that need to be considered to plot the graph. R # Load the default dataset (iris) data(iris) # Plotting the scatter plot using ggplot2 package fig1<-ggplot2::ggplot(aes (Sepal.Length,Sepal.Width),data=iris)+geom_point() # Plotting the Hull Plot using ggforce package fig2 <- fig1 + ggforce::geom_mark_hull(aes (fill=Species,label=Species),concavity=2) # Customized Hull Plot fig3 <- fig2 + ggforce::geom_mark_hull (aes(fill=Species,label=Species),concavity=2)+ expand_limits(x=8.5,y=5.0)+ labs(title="Customized Hull Plot using R", subtitle = "Iris Dataset", x="Sepal Length",y="Sepal Width") print(fig3) Output: Comment More infoAdvertise with us Next Article Visualizing clusters using Hull Plots in ggplot2 using ggforce S sri06harsha Follow Improve Article Tags : Technical Scripter R Language Technical Scripter 2022 Similar Reads Plot from DataFrame in ggplot2 using R ggplot2 is a popular data visualization library in the R programming language. It is widely used for creating beautiful, customizable, and informative visualizations. One of the most useful features of ggplot2 is the ability to plot data stored in a data frame. In this article, we will learn how to 4 min read Interactive Data Visualizations in R Using ggiraph Interactive data visualizations can significantly enhance the ability to explore and understand complex datasets. In R, the ggiraph package allows you to create interactive versions of ggplot2 visualizations. This article will provide an overview of ggiraph, its key features, and step-by-step exampl 5 min read How to Plot in 3D clusters using plotly package R-Language is widely used in Data Science, Data Visualization Data Analysis many more, etc. Plotly package is highly rich in plotting various graphs, These graphs/charts are highly interactive and user-friendly. The 3D cluster visualizes the similarity between variables as 3-D spatial relationships. 2 min read Working with Axes in R using ggplot2 The ggplot2 package is a powerful and widely used package for graphic visualization. It can be used to provide a lot of aesthetic mappings to the plotted graphs. This package is widely available in the R Programming Language. The package can be downloaded and installed into the working space using t 7 min read How to create a faceted line-graph using ggplot2 in R ? A potent visualization tool that enables us to investigate the relationship between two variables at various levels of a third-category variable is the faceted line graph. The ggplot2 tool in R offers a simple and versatile method for making faceted line graphs. This visual depiction improves our co 6 min read Like