1 / 5

Skill sharing: Combining base and ggplot2 graphics in R.

Skill sharing: Combining base and ggplot2 graphics in R. GLEON Fellowship Workshop January 14-18, 2013 Sunapee, NH Richard Iestyn Woolway. Plotting with R. R provides several frameworks for composing figures. The simplest is the base graphics.

ike
Download Presentation

Skill sharing: Combining base and ggplot2 graphics in R.

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Skill sharing: Combining base and ggplot2 graphics in R. GLEON Fellowship Workshop January 14-18, 2013 Sunapee, NH Richard IestynWoolway

  2. Plotting with R • R provides several frameworks for composing figures. • The simplest is the base graphics. • Another plotting system of R is ggplot2, which allows users to create publishable figures with ease. • Has a good book explaining the philosophy behind it: http://ggplot2.org/

  3. Plotting with R – base graphics • I recently needed to create a multi panel figure composed of a line plot, continuous wavelet transform, and the autocorrelation of a time series . • This can easily be created in base graphics using either par() or layout(). • I then decided to use ggplot2 to improve the quality of the acf plot in the third panel of the figure.

  4. Plotting with R – ggplot2 graphics • We can improve the quality of the acf plot with ggplot2: • However, as par() and layout() are only available with base graphics, we cannot mix base and ggplot graphics in a single figure window. • The most appropriate solution is to use the gridBasepackage. • The script called ‘RIW_code.R’ shows how gridBase is used.

  5. Integration of base and ggplot graphics • gridBase provides similar functionality to par(mfrow=c(x,y)). • This is an useful technique when we wish to create multiple panel figures that combines plots based on base graphics (e.g. biplots), that have not been implemented in grid (i.e. ggplot), and the task of re-implementing in grid is extremely daunting.

More Related