Quick distribution plotting with R


I was asked by new students in the Statistics and Data Analysis School of Tunis (and by others friends) about ways to plot densities and the best software to do that.

I will try to give some examples with  R software on how to plot density .

If you don't know what R is, you can take a look at my old article that explains that very well with some good R learning resources . ( here in French ).

You know that densities are all about random data and the first thing that comes in mind is histograms.

To start this task, we will first set the data sample that we will work with which should be random, and then we will start plotting some nice graphics with the ggplot2 library.

Basic things :Histogram and density plots:



regular histogram
where is the mean!

density plot
Overlay of density and histogram



Histograms and densities with multiple groups:



Overlaid histograms
Interleaved histograms

Density plots
Density plots with semi-transparent fill

Density plots with means
Overlaid histograms with means



Box-plots:


Basic Box-plot
A basic box with the conditions colored
     
legend removed
With flipped axes
   


So I hope this post would help you with plotting densities and histograms !

 It can be fun!






Popular posts from this blog

Mathematical Symbols in LATEX

Analyzing Twitter data with R (part 3: Cleaning & organizing the Data)

Linkin Park: Analyzing the causes of death of Rock band members