...

/

Plotting Data Using gplots

Plotting Data Using gplots

Learn to make unique and professional-quality bar plots with gplots.

Bar graph

We can learn how to use functions from the dplyr package to summarize our data. We produced a tibble called RP.means that contained the means and standard errors for SVL.initial for each combination of resource and predator treatments. Now, we’ll learn how to take that summarized data and turn it into a nice-looking figure. In particular, we’re going to make a bar graph.

Why are we making bar graph? There are several reasons for choosing a bar graph over other types of figures:

  • First, despite their ubiquity in publications, the R creators don’t like bar graphs (or bar plots, as we’ll call them), and making one is kind of a pain in R. This is because bar graphs can hide a lot about our data (they show the mean and whatever our error bar of choice is). But the fact that they’re challenging to create makes them an excellent tool for teaching many of the ways we can and probably should customize our figures. Having said that, boxplots are much more informative and are finally becoming increasingly used in published science.
  • The second reason is that despite their downsides, many people still like bar graphs and want to make them, so it’s helpful to know how to create one.

The most basic function to make a bar plot is the barplot() function. Many arguments can be passed to barplot(), which can be viewed in the help file.

The barplot2() function is a slightly improved version of the barplot() function, which makes the plotting of error bars much more straightforward. The barplot2() function is found in the gplots package. We can also make a ...