ggdistribution: How To Visualize Data Distributions in R Programming

Using the ggdistribution function in ggfortify can simplify your data visualization for probability distribution.

Pierre DeBois
3 min readMay 31, 2024
Image via Gemini

There are times when you have a data distribution you must use in your data model. One function that you would normally use with visualization is the venerable ggplot2 library. But that library is not the best choice for a data distribution.

A variation of ggplot2 makes displaying your distribution data much easier. The variant is called ggdistribution. It comes as part of the ggfortify library. ggdistribution helps to display the distribution of data easily.

When you use it, you apply the function to your data objects representing the probability distribution function or the cumulative distribution function. This means d and p distribution variants such as dbinom and pnorm are perfect choices for displaying the underlying data with ggdistribution.

For example, you have have a dnorm distribution within the ggdistribution() function. You can add parameters, such as the mean and standard deviation alongside the specified distribution. Here is what a basic dnorm example would look like (Note: this is based on the example that appears in CRAN).

--

--

Pierre DeBois

#analytics |#datascience |#JS |#rstats |#marketing services for #smallbiz | #retail | #nonprofits Contrib @CMSWire @smallbiztrends #blackbusiness #BLM