# One of the Best and Most Underutilized Graphs in ggplot2

**Hallway Mathlete**, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Understanding how a distribution of a variable changes over time can make a great visualization. These highly intuitive graphics can display a lot of information and can be simply rendered in R using ggplot2. However, based on my experience, they are one of the most underutilized graphs in R.

A good example of this style of graph is from my research. My research studies how data analysis can be utilized to improve the product design and manufacturing process. The style of graph discussed in this post is extremely useful for showing how design specifications change over time. Below you can see an example of how the specifications of secondary cameras on cellphones has changed over time. It is easily seen that before 2011, there was almost no secondary cameras and by 2015, almost all cameras released had some form of secondary camera.

To create these plots, first lets load ggplot2 and the diamond data set.

library(ggplot2) data(diamonds) head(diamonds)

ggplot(data=diamonds, aes(x=price, group=cut, fill=cut, position="stack")) + geom_density(adjust=1.5)

ggplot(data=diamonds,aes(x=price, group=cut, fill=cut, position="stack")) +

geom_density(adjust=1.5, position="fill")

ggplot(data=diamonds,aes(x=price, group=clarity, fill=clarity, position="stack")) + geom_density(adjust=1.5, position="fill")

**leave a comment**for the author, please follow the link and comment on their blog:

**Hallway Mathlete**.

R-bloggers.com offers

**daily e-mail updates**about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.