# Multiple Plots and Visualizing Distributions - Part 7 in a Series

This is post #07 in a running series about plotting in R.

I was helping a friend plot some interesting distributions this weekend, so I decided to use distributions to demonstrate one of the neater bits of R’s basic plotting tools: the ability to easily combine plots into a single plot.

par will allow you to manipulate all sorts of parameters to plots — you should eventually poke through the docs. Nonetheless, one of the simplest things to do is to add plots to a matrix plot. You can specify whether you want these to be row major or column major by using the mfrow or mfcol parameter respectively. Let’s take a look, and play with the uniform distribution while we’re at it:

From left to right, we see the density (dunif), distribution (punif) and quantile (quniff) plots for the Uniform[0,1] distribution. The first thing we might wish to do is to add a label to the left side of the combined plot saying what we’re plotting. To do this, we’ll have to adjust the margins for the combined plot, again using par:

Now, let’s suppose we wanted to use something like a LaTeX expression in our plots — we can do this using expression. For a complete explanation of the syntax, see plotmath.

Now that we’ve looked at 3 distributions, say we wanted to look at Uniform[0,1], Standard Normal, Exponential(rate=1) and Poisson(lambda=1) all on the same plot. par will allow us to do that:

There are a couple issues with this plot, still: there is no main title, the labels we carefully applied with mtext stomped all over each other, and we waste an awful lot of whitespace. Let’s take a stab at fixing all of the above: