Category Archives: ggplot2

Axes (ggplot)


A simple sequence of numbers is provided to populate the base graph.

Plot84aClick to enlarge

Axes Text Formats

The following examples modify axes text formats with colors and bold font so they are easier to see.  The second chart benefits from axis text being rotated 90 degrees.

Plot91 Plot92

Posted in ggplot2 | Leave a comment

The Grammar of Graphics

Comparison of Graphic Tools

When it comes to producing graphics in R, there are basically three choices:

  • Base graphics which ships with R,
  • the lattice package extension, and
  • the ggplot2 package extension.

Base graphics was described extensively in the previous few chapters, and is the preferred choice for creating highly customized charts, like the polar windrose plot below, where flexibility and control over all graph objects is essential:

Posted in ggplot2 | Leave a comment

Correlation Plots in R

The standard function for correlation plots in R is pairs(), which generates a matrix of scatter plots based on all pairwise combinations of variables in a data object.  The standard graph looks something like this after a little color enhancement:” plot13Click to enlarge

The code behind this plot is simple:

Posted in Data Science, ggplot2, R Graphics, R Programming | Comments Off on Correlation Plots in R

R Graphics (ggplot2)

The flexibility of R graphics using the package ggplot is illustrated through a series of structured examples.  

The Grammar of Graphics
Building Layered Plots
Scatter Plots (ggplot)
Bar Graphs (ggplot)
Line Graphs (ggplot)
Boxplots (ggplot)
Error Bars (ggplot)
Facetting (ggplot)
Titles (ggplot)
Axes (ggplot)
Legends (ggplot)
Other Geoms (ggplot)
Multiple Plots (ggplot)
Themes (ggplot)

Back | Next

Posted in ggplot2 | Leave a comment