R Graphics, 2nd Edition

Book description

Extensively updated to reflect the evolution of statistics and computing, the second edition of the bestselling R Graphics comes complete with new packages and new examples. Paul Murrell, widely known as the leading expert on R graphics, has developed an in-depth resource that helps both neophyte and seasoned users master the intricacies of R graph

Table of contents

  1. Preliminaries
  2. Series
  3. Preface
    1. What this book is about
    2. Changes in the second edition
    3. What this book is still not about
    4. Who should read this book
    5. Conventions used in this book
    6. On the web
    7. Version information
    8. Acknowledgments
  4. Chapter 1 An Introduction to R Graphics
    1. 1.1 R graphics examples
      1. 1.1.1 Standard plots
      2. 1.1.2 Trellis plots
      3. 1.1.3 The Grammar of Graphics
      4. 1.1.4 Specialized plots
      5. 1.1.5 General graphical scenes
    2. 1.2 The organization of R graphics
      1. 1.2.1 Types of graphics functions
      2. 1.2.2 Traditional graphics versus grid graphics
      1. Figure 1.1
      2. Figure 1.2
      3. Figure 1.3
      4. Figure 1.4
      5. Figure 1.5
      6. Figure 1.6
      7. Figure 1.7
      8. Figure 1.8
      9. Figure 1.9
      10. Figure 1.10
      11. Figure 1.11
      12. Figure 1.12
      13. Figure 1.13
      14. Figure 1.14
  5. Part I TRADITIONAL GRAPHICS
    1. Chapter 2 Simple Usage of Traditional Graphics
      1. 2.1 The traditional graphics model
      2. 2.2 The plot() function
      3. 2.3 Plots of a single variable
      4. 2.4 Plots of two variables
      5. 2.5 Plots of many variables
      6. 2.6 Arguments to graphics functions
        1. 2.6.1 Standard arguments to graphics functions
      7. 2.7 Specialized plots
      8. 2.8 Interactive graphics
        1. Figure 2.1
        2. Figure 2.2
        3. Figure 2.3
        4. Figure 2.4
        5. Figure 2.5
        6. Figure 2.6
        7. Figure 2.7
        8. Figure 2.8
        9. Figure 2.9
        1. Table 2.1
        2. Table 2.2
        3. Table 2.3
    2. Chapter 3 Customizing Traditional Graphics
      1. 3.1 The traditional graphics model in more detail
        1. 3.1.1 Plotting regions
          1. Coordinate systems
        2. 3.1.2 The traditional graphics state
      2. 3.2 Controlling the appearance of plots
        1. 3.2.1 Colors
          1. Fill patterns
        2. 3.2.2 Lines
        3. 3.2.3 Text
          1. Text size
          2. Specifying fonts
          3. Justification of text
          4. Rotating text
          5. Multi-line text
        4. 3.2.4 Data symbols
        5. 3.2.5 Axes
        6. 3.2.6 Plotting regions
          1. Outer margins
          2. Figure regions
          3. Figure margins
          4. Plot regions
        7. 3.2.7 Clipping
        8. 3.2.8 Moving to a new plot
      3. 3.3 Arranging multiple plots
        1. 3.3.1 Using the traditional graphics state
        2. 3.3.2 Layouts
        3. 3.3.3 The split-screen approach
      4. 3.4 Annotating plots
        1. 3.4.1 Annotating the plot region
          1. Graphical primitives
          2. Graphical utilities
          3. Missing values and non-finite values
        2. 3.4.2 Annotating the margins
        3. 3.4.3 Legends
        4. 3.4.4 Axes
        5. 3.4.5 Coordinate systems
          1. The par() function
          2. Overlaying output
        6. 3.4.6 Special cases
          1. Obscure scales on axes
          2. Functions that draw several plots
          3. 3D plots
      5. 3.5 Creating new plots
        1. 3.5.1 A simple plot from scratch
        2. 3.5.2 A more complex plot from scratch
        3. 3.5.3 Writing traditional graphics functions
          1. Helper functions
          2. Argument lists
          3. Plot methods
          4. A graphics function template
        1. Figure 3.1
        2. Figure 3.2
        3. Figure 3.3
        4. Figure 3.4
        5. Figure 3.5
        6. Figure 3.6
        7. Figure 3.7
        8. Figure 3.8
        9. Figure 3.9
        10. Figure 3.10
        11. Figure 3.11
        12. Figure 3.12
        13. Figure 3.13
        14. Figure 3.14
        15. Figure 3.15
        16. Figure 3.16
        17. Figure 3.17
        18. Figure 3.18
        19. Figure 3.19
        20. Figure 3.20
        21. Figure 3.21
        22. Figure 3.22
        23. Figure 3.23
        24. Figure 3.24
        25. Figure 3.25
        26. Figure 3.26
        27. Figure 3.27
        28. Figure 3.28
        1. Table 3.1
        2. Table 3.2
        3. Table 3.3
        4. Table 3.4
        5. Table 3.5
  6. Part II GRID GRAPHICS
    1. Chapter 4 Trellis Graphics: The lattice Package
      1. 4.1 The lattice graphics model
        1. 4.1.1 Why another graphics system?
      2. 4.2 lattice plot types
      3. 4.3 The formula argument and multipanel conditioning
      4. 4.4 The group argument and legends
      5. 4.5 The layout argument and arranging plots
      6. 4.6 The scales argument and labeling axes
      7. 4.7 The panel argument and annotating plots
        1. 4.7.1 Adding output to a lattice plot
      8. 4.8 par.settings and graphical parameters
      9. 4.9 Extending lattice plots
        1. 4.9.1 The latticeExtra package
        1. Figure 4.1
        2. Figure 4.2
        3. Figure 4.3
        4. Figure 4.4
        5. Figure 4.5
        6. Figure 4.6
        7. Figure 4.7
        8. Figure 4.8
        9. Figure 4.9
        10. Figure 4.10
        11. Figure 4.11
        12. Figure 4.12
        13. Figure 4.13
        1. Table 4.1
        2. Table 4.2
        3. Table 4.3
        4. Table 4.4
    2. Chapter 5 The Grammar of Graphics: The ggplot2 Package
      1. 5.1 Quick plots
      2. 5.2 The ggplot2 graphics model
        1. 5.2.1 Why another graphics system?
        2. 5.2.2 An example data set
      3. 5.3 Data
      4. 5.4 Geoms and aesthetics
      5. 5.5 Scales
      6. 5.6 Statistical transformations
      7. 5.7 The group aesthetic
      8. 5.8 Position adjustments
      9. 5.9 Coordinate transformations
      10. 5.10 Facets
      11. 5.11 Themes
      12. 5.12 Annotating
      13. 5.13 Extending ggplot2
        1. Figure 5.1
        2. Figure 5.2
        3. Figure 5.3
        4. Figure 5.4
        5. Figure 5.5
        6. Figure 5.6
        7. Figure 5.7
        8. Figure 5.8
        9. Figure 5.9
        10. Figure 5.10
        11. Figure 5.11
        12. Figure 5.12
        13. Figure 5.13
        14. Figure 5.14
        15. Figure 5.15
        1. Table 5.1
        2. Table 5.2
        3. Table 5.3
        4. Table 5.4
    3. Chapter 6 The grid Graphics Model
      1. 6.1 A brief overview of grid graphics
        1. 6.1.1 A simple example
      2. 6.2 Graphical primitives
        1. 6.2.1 Standard arguments
        2. 6.2.2 Clipping
      3. 6.3 Coordinate systems
        1. 6.3.1 Conversion functions
        2. 6.3.2 Complex units
      4. 6.4 Controlling the appearance of output
        1. 6.4.1 Specifying graphical parameter settings
        2. 6.4.2 Vectorized graphical parameter settings
      5. 6.5 Viewports
        1. 6.5.1 Pushing, popping, and navigating between viewports
          1. Drawing between viewports
        2. 6.5.2 Clipping to viewports
        3. 6.5.3 Viewport lists, stacks, and trees
          1. Viewport paths
        4. 6.5.4 Viewports as arguments to graphical primitives
        5. 6.5.5 Graphical parameter settings in viewports
        6. 6.5.6 Layouts
          1. A simple layout
          2. A layout with units
          3. A nested layout
      6. 6.6 Missing values and non-finite values
      7. 6.7 Interactive graphics
      8. 6.8 Customizing lattice plots
        1. 6.8.1 Adding grid output to lattice output
        2. 6.8.2 Adding lattice output to grid output
      9. 6.9 Customizing ggplot2 output
        1. 6.9.1 Adding grid output to ggplot2 output
        2. 6.9.2 Adding ggplot2 output to grid output
        1. Figure 6.1
        2. Figure 6.2
        3. Figure 6.3
        4. Figure 6.4
        5. Figure 6.5
        6. Figure 6.6
        7. Figure 6.7
        8. Figure 6.8
        9. Figure 6.9
        10. Figure 6.10
        11. Figure 6.11
        12. Figure 6.12
        13. Figure 6.13
        14. Figure 6.14
        15. Figure 6.15
        16. Figure 6.16
        17. Figure 6.17
        18. Figure 6.18
        19. Figure 6.19
        20. Figure 6.20
        21. Figure 6.21
        22. Figure 6.22
        23. Figure 6.23
        24. Figure 6.24
        25. Figure 6.25
        26. Figure 6.26
        1. Table 6.1
        2. Table 6.2
        3. Table 6.3
        4. Table 6.4
    4. Chapter 7 The grid Graphics Object Model
      1. 7.1 Working with graphical output
        1. 7.1.1 Standard functions and arguments
      2. 7.2 Grob lists, trees, and paths
        1. 7.2.1 Graphical parameter settings in gTrees
        2. 7.2.2 Viewports as components of gTrees
        3. 7.2.3 Searching for grobs
      3. 7.3 Working with graphical objects off-screen
        1. 7.3.1 Capturing output
      4. 7.4 Placing and packing grobs in frames
        1. 7.4.1 Placing and packing off-screen
      5. 7.5 Other details about grobs
        1. 7.5.1 Calculating the sizes of grobs
        2. 7.5.2 Calculating the positions of grobs
        3. 7.5.3 Editing graphical context
      6. 7.6 Saving and loading grid graphics
      7. 7.7 Working with lattice grobs
      8. 7.8 Working with ggplot2 grobs
        1. Figure 7.1
        2. Figure 7.2
        3. Figure 7.3
        4. Figure 7.4
        5. Figure 7.5
        6. Figure 7.6
        7. Figure 7.7
        8. Figure 7.8
        9. Figure 7.9
        10. Figure 7.10
        11. Figure 7.11
        12. Figure 7.12
        13. Figure 7.13
        1. Table 7.1
    5. Chapter 8 Developing New Graphics Functions and Objects
      1. 8.1 An example
        1. 8.1.1 Modularity
      2. 8.2 Simple graphics functions
        1. 8.2.1 Embedding graphical output
        2. 8.2.2 Facilitating annotation
        3. 8.2.3 Editing output
        4. 8.2.4 Absolute versus relative sizes
      3. 8.3 Graphical objects
        1. 8.3.1 Overview of creating a new graphical class
        2. 8.3.2 Defining a new graphical class
          1. Summary of creating a new graphical class
        3. 8.3.3 Validating grobs
          1. Default validating behavior
          2. The imageGrob example
        4. 8.3.4 Drawing grobs
          1. Default drawing behavior
          2. The imageGrob example
          3. An ozGrob example
          4. An ozImage example
        5. 8.3.5 Editing grobs
          1. Default editing behavior
          2. The imageGrob example
          3. The ozGrob example
          4. The ozImage example
          5. The imageGrob example again
          6. The ozImage example again
        6. 8.3.6 Querying grobs
          1. Default sizing behavior
          2. A ribbonLegend example
        7. 8.3.7 Pre-drawing and post-drawing
          1. Default pre/post-drawing behavior
        8. 8.3.8 Summary of graphical object methods
        9. 8.3.9 Completing the example
        10. 8.3.10 Reusing graphical elements
        11. 8.3.11 Other details
          1. Extending other grobs
          2. Display lists
          3. Calculations during drawing
          4. Avoiding argument explosion
          5. Mixing graphical functions and graphical objects
      4. 8.4 Debugging grid
        1. Figure 8.1
        2. Figure 8.2
        3. Figure 8.3
        4. Figure 8.4
        5. Figure 8.5
        6. Figure 8.6
        7. Figure 8.7
        8. Figure 8.8
        9. Figure 8.9
        10. Figure 8.10
        11. Figure 8.11
        12. Figure 8.12
        13. Figure 8.13
        14. Figure 8.14
        15. Figure 8.15
        16. Figure 8.16
        17. Figure 8.17
        18. Figure 8.18
        19. Figure 8.19
        20. Figure 8.20
        21. Figure 8.21
        22. Figure 8.22
        23. Figure 8.23
        24. Figure 8.24
        25. Figure 8.25
        26. Figure 8.26
        27. Figure 8.27
  7. Part III THE GRAPHICS ENGINE
    1. Chapter 9 Graphics Formats
      1. 9.1 Graphics devices
      2. 9.2 Graphical output formats
        1. 9.2.1 Vector formats
          1. PDF
          2. PostScript
          3. SVG
          4. Windows Metafile
        2. 9.2.2 Raster formats
      3. 9.3 Including R graphics in other documents
        1. 9.3.1 LATEX
        2. 9.3.2 “Productivity” software
        3. 9.3.3 Web pages
      4. 9.4 Device-specific features
      5. 9.5 Multiple pages of output
      6. 9.6 Display lists
      7. 9.7 Extension packages
        1. Table 9.1
        2. Table 9.2
    2. Chapter 10 Graphical Parameters
      1. 10.1 Colors
        1. 10.1.1 Semitransparent colors
        2. 10.1.2 Converting colors
        3. 10.1.3 Color sets
        4. 10.1.4 Device Dependency of Color Specifications
      2. 10.2 Line styles
        1. 10.2.1 Line widths
        2. 10.2.2 Line types
        3. 10.2.3 Line ends and joins
      3. 10.3 Data symbols
      4. 10.4 Fonts
        1. 10.4.1 Font family
        2. 10.4.2 Font face
        3. 10.4.3 Multi-line text
        4. 10.4.4 Locales
      5. 10.5 Mathematical formulae
        1. Figure 10.1
        2. Figure 10.2
        3. Figure 10.3
        4. Figure 10.4
        1. Table 10.1
        2. Table 10.2
        3. Table 10.3
  8. Part IV GRAPHICS PACKAGES
    1. Chapter 11 Graphics Extensions
      1. 11.1 Tricks with text
        1. 11.1.1 Drawing formatted text on a plot
        2. 11.1.2 Avoiding text overlaps
      2. 11.2 Peculiar primitives
        1. 11.2.1 Confidence bars
      3. 11.3 Calculations on colors
        1. 11.3.1 The colorspace package
        2. 11.3.2 The RColorBrewer package
        3. 11.3.3 The munsell package
        4. 11.3.4 The dichromat package
      4. 11.4 Custom coordinates
        1. 11.4.1 Converting between traditional coordinate systems
        2. 11.4.2 Subplots
      5. 11.5 Atypical axes
        1. Figure 11.1
        2. Figure 11.2
        3. Figure 11.3
        4. Figure 11.4
        5. Figure 11.5
        6. Figure 11.6
        7. Figure 11.7
        8. Figure 11.8
        9. Figure 11.9
        10. Figure 11.10
        11. Figure 11.11
        12. Figure 11.12
        13. Figure 11.13
    2. Chapter 12 Plot Extensions
      1. 12.1 Venn diagrams
      2. 12.2 Chernoff faces
      3. 12.3 Ternary plots
        1. 12.3.1 Soil texture diagrams
      4. 12.4 Polar plots
        1. 12.4.1 Wind roses
      5. 12.5 Hexagonal binning
        1. Figure 12.1
        2. Figure 12.2
        3. Figure 12.3
        4. Figure 12.4
        5. Figure 12.5
        6. Figure 12.6
        7. Figure 12.7
    3. Chapter 13 Graphics for Categorical Data
      1. 13.1 The vcd package
      2. 13.2 XMM-Newton
      3. 13.3 Plots of categorical data
      4. 13.4 Categorical data on the y-axis
      5. 13.5 Visualizing contingency tables
      6. 13.6 Categorical plot matrices
      7. 13.7 Multipanel categorical plots
      8. 13.8 Customizing categorical plots
      9. 13.9 The vcdExtra package
        1. Figure 13.1
        2. Figure 13.2
        3. Figure 13.3
        4. Figure 13.4
        5. Figure 13.5
        6. Figure 13.6
        7. Figure 13.7
        8. Figure 13.8
    4. Chapter 14 Maps
      1. 14.1 Map data
        1. 14.1.1 The maps package
        2. 14.1.2 Shapefiles
      2. 14.2 Map annotation
      3. 14.3 Complex polygons
      4. 14.4 Map projections
      5. 14.5 Raster maps
      6. 14.6 Other packages
        1. Figure 14.1
        2. Figure 14.2
        3. Figure 14.3
        4. Figure 14.4
        5. Figure 14.5
        6. Figure 14.6
        7. Figure 14.7
        8. Figure 14.8
        9. Figure 14.9
        10. Figure 14.10
        11. Figure 14.11
    5. Chapter 15 Node-and-edge Graphs
      1. 15.1 Creating graphs
        1. 15.1.1 The graph package
      2. 15.2 Graph layout and rendering
        1. 15.2.1 The Rgraphviz package
        2. 15.2.2 Graph attributes
        3. 15.2.3 Customization
        4. 15.2.4 Output formats
        5. 15.2.5 Hypergraphs
      3. 15.3 Other packages
        1. 15.3.1 The igraph package
        2. 15.3.2 The network package
      4. 15.4 Diagrams
        1. 15.4.1 The diagram and shape packages
        1. Figure 15.1
        2. Figure 15.2
        3. Figure 15.3
        4. Figure 15.4
        5. Figure 15.5
        6. Figure 15.6
        7. Figure 15.7
        8. Figure 15.8
        9. Figure 15.9
        10. Figure 15.10
    6. Chapter 16 3D Graphics
      1. 16.1 3D graphics concepts
      2. 16.2 The Canterbury earthquake
      3. 16.3 Traditional graphics
      4. 16.4 lattice graphics
      5. 16.5 The scatterplot3d package
      6. 16.6 The rgl package
      7. 16.7 The vrmlgen package
        1. Figure 16.1
        2. Figure 16.2
        3. Figure 16.3
        4. Figure 16.4
        5. Figure 16.5
        6. Figure 16.6
        7. Figure 16.7
        8. Figure 16.8
        9. Figure 16.9
        10. Figure 16.10
        11. Figure 16.11
    7. Chapter 17 Dynamic and Interactive Graphics
      1. 17.1 Dynamic graphics
        1. 17.1.1 The animation package
      2. 17.2 Interactive graphics
        1. 17.2.1 Tools and techniques
        2. 17.2.2 The rggobi package
          1. Tours
        3. 17.2.3 The iplots package
          1. Developing new interactive plots
      3. 17.3 Graphics GUIs
        1. 17.3.1 GUIs for R
        2. 17.3.2 GUI toolkits
          1. An interactive clock
          2. The gWidgets package
      4. 17.4 Interactive graphics for the web
        1. Figure 17.1
        2. Figure 17.2
        3. Figure 17.3
        4. Figure 17.4
        5. Figure 17.5
        6. Figure 17.6
        7. Figure 17.7
        8. Figure 17.8
        9. Figure 17.9
        10. Figure 17.10
        11. Figure 17.11
        12. Figure 17.12
        13. Figure 17.13
        14. Figure 17.14
        15. Figure 17.15
        16. Figure 17.16
    8. Chapter 18 Importing Graphics
      1. 18.1 The Moon and the tides
      2. 18.2 Importing raster graphics
        1. 18.2.1 Manipulating raster images
      3. 18.3 Importing vector graphics
        1. 18.3.1 The grImport package
        2. 18.3.2 Manipulating vector images
        1. Figure 18.1
        2. Figure 18.2
        3. Figure 18.3
        4. Figure 18.4
        5. Figure 18.5
        6. Figure 18.6
        1. Table 18.1
    9. Chapter 19 Combining Graphics Systems
      1. 19.1 The gridBase package
        1. 19.1.1 Annotating traditional graphics using grid
        2. 19.1.2 Traditional graphics in grid viewports
        3. 19.1.3 Problems and limitations
        1. Figure 19.1
        2. Figure 19.2
  9. Bibliography

Product information

  • Title: R Graphics, 2nd Edition
  • Author(s): Paul Murrell
  • Release date: November 2018
  • Publisher(s): CRC Press
  • ISBN: 9781498759625