How to Make a Histogram with ggvis in R Last Updated : 28 Apr, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report In R Programming ggvis is the successor of ggplot package which is used to visualize data. Mainly ggvis package is introduced to plot HTML graphs so that these plots can be used in shiny web applications with short efforts. The layer_histogram() in ggvis is used to ensure the plot is a Histogram Plot. Syntax of layer_histograms() function of ggvis package Syntax: df %>% ggvis(~df) %>% layer_histograms(boundary) Where, df : The dataframe that need to be plotted.~df: The Column of the data frame to be plotted is specified here.boundary: It is used to specify boundary of bar in the histogram.Example 1: Creating Histogram with ggvis Install and load the required package and Load or Create the dataset as a Dataframe. Here, we are using the default dataset iris for our article, you are free to choose any dataset to plot the Histogram with ggvis in R. Using the layer_histograms() function of ggvis package we are going to plot the Histogram Plot. R # Install ggvis package install.packages("ggvis") # Load the installed package library(ggvis) # Load the default dataset (iris) data(iris) # Convert that dataset to data frame df <- data.frame(iris) iris %>% ggvis(~iris$Sepal.Length) %>% layer_histograms(boundary = 1) Output: Example 2: Add Label and Title The plot can also be customized by adding x, and y-axis labels and a title to the plot as follows R iris %>% ggvis(~iris$Sepal.Length,fill:="blue") %>% layer_histograms() %>% add_axis("x", title = "Sepal Length") %>% add_axis("y", title = "Counts") %>% add_axis("x",title = "Histogram Plot using ggvis",orient="top") Output: Example 3: Adjust width of bin Adjustment of the width of the bars can also be done using the width parameter in the layer_histograms() function to make sure the graph is precise with less number of bins. As there were no parameters like in ggplot to specify the number of bins in ggvis the width of the bin [ The individual bars are known as Bins] is inversely proportional to the number of bins here. R library(ggvis) iris %>% ggvis(~iris$Sepal.Length,fill:="blue") %>% layer_histograms(width=1) %>% add_axis("x", title = "Sepal Length") %>% add_axis("y", title = "Counts") %>% add_axis("x",title = "Histogram Plot using ggvis",orient="top") Output: Comment More infoAdvertise with us Next Article How to Make a Histogram in Excel: 3 Easy Methods S sri06harsha Follow Improve Article Tags : Technical Scripter R Language Technical Scripter 2022 Similar Reads How to Make a Simple Histogram with Altair in Python? Prerequisites: Altair Simple Histogram is the representation of frequency distribution by means of rectangles whose width represents the class interval. Histogram is the graphical representation that organizes grouped data points into the specified range. By using histogram we can visualize large am 4 min read How to Make a Histogram in Excel: 3 Easy Methods A histogram is a vital tool for analyzing and visualizing the distribution of data, allowing users to easily identify patterns, trends, and outliers. Commonly used in statistics and data-driven decision-making, histograms help present data frequency in a structured and readable format. Excel provide 6 min read How to plot a Histogram in MATLAB ? A Histogram is a diagrammatic representation of a group of data over user-specified ranges. Basically, the histogram contains several bins. Bins are non-overlapping intervals in which the data is spread. In MATLAB we have a function named hist() which allows us to plot a bar graph. Syntax: hist(X) 2 min read How To Make Scatterplot with Marginal Histograms in R? In this article, we will discuss how to make a Scatterplot with Marginal Histograms in the R Language. Marginal Histograms in R: A scatter plot and separate histograms for each variable on their respective axes are both combined in a marginal histogram, which is a visualization approach. Using this 6 min read How to Make ECDF Plot with ggplot2 in R? Empirical Cumulative Distribution Function Plot (ECDF) helps us to visualize one or more distributions. ECDF plot is a great alternative for histograms and it has the ability to show the full range of data without the need for various parameters. In this article, we will discuss how to draw an ECDF 3 min read How to Make Grouped Boxplots with ggplot2 in R? In this article, we will discuss how to make a grouped boxplot in the R Programming Language using the ggplot2 package. Boxplot helps us to visualize the distribution of quantitative data comparing different continuous or categorical variables. Boxplots consist of a five-number summary which helps i 3 min read Like