Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
R Graphs Cookbook Second Edition
Table of Contents
R Graphs Cookbook Second Edition
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. R Graphics
Base graphics using the default package
Trellis graphs using lattice
Graphs inspired by Grammar of Graphics
2. Basic Graph Functions
Introduction
Creating basic scatter plots
Getting ready
How to do it...
How it works...
There's more...
A note on R's built-in datasets
See also
Creating line graphs
Getting ready
How to do it...
How it works...
There's more...
See also
Creating bar charts
Getting ready
How to do it...
How it works...
There's more...
See also
Creating histograms and density plots
How to do it...
How it works...
There's more...
See also
Creating box plots
Getting ready
How to do it...
How it works...
There's more...
See also
Adjusting x and y axes' limits
How to do it...
How it works...
There's more...
See also
Creating heat maps
How to do it...
How it works...
There's more...
See also
Creating pairs plots
How to do it...
How it works...
There's more...
See also
Creating multiple plot matrix layouts
How to do it...
How it works...
There's more...
See also
Adding and formatting legends
Getting ready
How to do it...
How it works...
There's more...
See also
Creating graphs with maps
Getting ready
How to do it...
How it works...
There's more...
See also
Saving and exporting graphs
How to do it...
How it works...
There's more...
See also
3. Beyond the Basics – Adjusting Key Parameters
Introduction
Setting colors of points, lines, and bars
Getting ready
How to do it...
How it works...
There's more...
See also
Setting plot background colors
Getting ready
How to do it...
How it works...
There's more...
Setting colors for text elements – axis annotations, labels, plot titles, and legends
Getting ready
How to do it...
How it works...
There's more...
Choosing color combinations and palettes
Getting ready
How to do it...
How it works...
There's more...
See also
Setting fonts for annotations and titles
Getting ready
How to do it...
How it works...
There's more...
See also
Choosing plotting point symbol styles and sizes
Getting ready
How to do it...
How it works...
There's more...
See also
Choosing line styles and width
Getting ready
How to do it...
How it works...
See also
Choosing box styles
Getting ready
How to do it...
How it works...
There's more...
Adjusting axis annotations and tick marks
Getting ready
How to do it...
How it works...
There's more...
See also
Formatting log axes
Getting ready
How to do it...
How it works...
There's more...
Setting graph margins and dimensions
Getting ready
How to do it...
How it works...
See also
4. Creating Scatter Plots
Introduction
Grouping data points within a scatter plot
Getting ready
How to do it...
How it works...
There's more...
See also
Highlighting grouped data points by size and symbol type
Getting ready
How to do it...
How it works...
Labeling data points
Getting ready
How to do it...
How it works...
There's more...
Correlation matrix using pairs plots
Getting ready
How to do it...
How it works...
Adding error bars
Getting ready
How to do it...
How it works...
There's more...
Using jitter to distinguish closely packed data points
Getting ready
How to do it...
How it works...
Adding linear model lines
Getting ready
How to do it...
How it works...
Adding nonlinear model curves
Getting ready
How to do it...
How it works...
Adding nonparametric model curves with lowess
Getting ready
How to do it...
How it works...
Creating three-dimensional scatter plots
Getting ready
How to do it...
How it works...
There's more...
Creating Quantile-Quantile plots
Getting ready
How to do it...
How it works...
There's more...
Displaying the data density on axes
Getting ready
How to do it...
How it works...
There's more...
Creating scatter plots with a smoothed density representation
Getting ready
How to do it...
How it works...
There's more...
5. Creating Line Graphs and Time Series Charts
Introduction
Adding customized legends for multiple-line graphs
Getting ready
How to do it...
How it works...
There's more...
See also
Using margin labels instead of legends for multiple-line graphs
Getting ready
How to do it...
How it works...
There's more...
Adding horizontal and vertical grid lines
Getting ready
How to do it...
How it works...
There's more...
See also
Adding marker lines at specific x and y values using abline
Getting ready
How to do it...
How it works...
There's more...
Creating sparklines
Getting ready
How to do it...
How it works...
Plotting functions of a variable in a dataset
Getting ready
How to do it...
How it works...
There's more...
Formatting time series data for plotting
Getting ready
How to do it...
How it works...
There's more...
Plotting the date or time variable on the x axis
Getting ready
How to do it...
How it works...
There's more...
Annotating axis labels in different human-readable time formats
Getting ready
How to do it...
How it works...
There's more...
Adding vertical markers to indicate specific time events
Getting ready
How to do it...
How it works...
There's more...
Plotting data with varying time-averaging periods
Getting ready
How to do it...
How it works...
Creating stock charts
Getting ready
How to do it...
How it works...
There's more...
6. Creating Bar, Dot, and Pie Charts
Introduction
Creating bar charts with more than one factor variable
Getting ready
How to do it...
How it works...
See also
Creating stacked bar charts
Getting ready
How to do it...
How it works...
There's more...
Adjusting the orientation of bars – horizontal and vertical
Getting ready
How to do it...
How it works...
There's more...
Adjusting bar widths, spacing, colors, and borders
Getting ready
How to do it...
How it works...
There's more...
Displaying values on top of or next to the bars
Getting ready
How to do it...
How it works...
There's more...
See also
Placing labels inside bars
Getting ready
How to do it...
How it works...
There's more...
Creating bar charts with vertical error bars
Getting ready
How to do it...
How it works...
There's more...
Modifying dot charts by grouping variables
Getting ready
How to do it...
How it works...
Making better, readable pie charts with clockwise-ordered slices
Getting ready
How to do it...
How it works...
See also
Labeling a pie chart with percentage values for each slice
Getting ready
How to do it...
How it works...
There's more...
See also
Adding a legend to a pie chart
Getting ready
How to do it...
How it works...
There's more...
7. Creating Histograms
Introduction
Visualizing distributions as count frequencies or probability densities
Getting ready
How to do it...
How it works...
There's more
Setting the bin size and the number of breaks
Getting ready
How to do it...
How it works...
There's more
Adjusting histogram styles – bar colors, borders, and axes
Getting ready
How to do it...
How it works...
There's more
Overlaying a density line over a histogram
Getting ready
How to do it...
How it works...
Multiple histograms along the diagonal of a pairs plot
Getting ready
How to do it...
How it works...
Histograms in the margins of line and scatter plots
Getting ready
How to do it...
How it works...
8. Box and Whisker Plots
Introduction
Creating box plots with narrow boxes for a small number of variables
Getting ready
How to do it...
How it works...
There's more
See also
Grouping over a variable
Getting ready
How to do it...
How it works...
There's more
See also
Varying box widths by the number of observations
Getting ready
How to do it...
How it works...
Creating box plots with notches
Getting ready
How to do it...
How it works...
There's more
Including or excluding outliers
Getting ready
How to do it...
How it works...
See also
Creating horizontal box plots
Getting ready
How to do it...
How it works...
Changing the box styling
Getting ready
How to do it...
How it works...
There's more
Adjusting the extent of plot whiskers outside the box
Getting ready
How to do it...
How it works...
There's more
Showing the number of observations
Getting ready
How to do it...
How it works...
There's more
Splitting a variable at arbitrary values into subsets
Getting ready
How to do it...
How it works...
There's more
9. Creating Heat Maps and Contour Plots
Introduction
Creating heat maps of a single Z variable with a scale
Getting ready
How to do it...
How it works...
There's more
See also
Creating correlation heat maps
Getting ready
How to do it...
How it works...
There's more
Summarizing multivariate data in a single heat map
Getting ready
How to do it...
How it works...
There's more
Creating contour plots
Getting ready
How to do it...
How it works...
There's more
See also
Creating filled contour plots
Getting ready
How to do it...
How it works...
There's more
See also
Creating three-dimensional surface plots
Getting ready
How to do it...
How it works...
There's more
Visualizing time series as calendar heat maps
Getting ready
How to do it...
How it works...
There's more
10. Creating Maps
Introduction
Plotting global data by countries on a world map
Getting ready
How to do it...
How it works...
There's more
See also
Creating graphs with regional maps
Getting ready
How to do it...
How it works...
There's more
Plotting data on Google maps
Getting ready
How to do it...
How it works...
There's more
See also
Creating and reading KML data
Getting ready
How to do it...
How it works...
See Also
Working with ESRI shapefiles
Getting ready
How to do it...
How it works...
There's more
11. Data Visualization Using Lattice
Introduction
Creating bar charts
Getting ready
How to do it…
How it works…
There's more…
See also
Creating stacked bar charts
Getting ready
How to do it…
How it works…
There's more…
See also
Creating bar charts to visualize cross-tabulation
Getting ready
How to do it…
How it works…
There's more…
Creating a conditional histogram
Getting ready
How to do it…
How it works…
There's more…
See also
Visualizing distributions through a kernel-density plot
Getting ready
How to do it…
How it works…
There's more…
Creating a normal Q-Q plot
Getting ready
How to do it…
How it works…
There's more…
Visualizing an empirical Cumulative Distribution Function
Getting ready
How to do it…
How it works…
There's more…
Creating a boxplot
Getting ready
How to do it…
How it works…
There's more…
Creating a conditional scatter plot
Getting ready
How to do it…
How it works…
There's more…
12. Data Visualization Using ggplot2
Introduction
Creating bar charts
Getting ready
How to do it…
How it works…
There's more…
See also
Creating multiple bar charts
Getting ready
How to do it…
How it works…
There's more…
See also
Creating a bar chart with error bars
Getting ready
How to do it…
How it works…
There's more…
Visualizing the density of a numeric variable
Getting ready
How to do it...
How it works…
There's more...
Creating a box plot
Getting ready
How to do it...
How it works…
Creating a layered plot with a scatter plot and fitted line
Getting ready
How to do it...
How it works…
There's more...
Creating a line chart
Getting ready
How to do it...
How it works…
There's more...
Graph annotation with ggplot
Getting ready
How to do it...
How it works...
13. Inspecting Large Datasets
Introduction
Multivariate continuous data visualization
Getting ready
How to do it…
How it works…
There's more…
See also
Multivariate categorical data visualization
Getting ready
How to do it…
How it works…
There's more…
Visualizing mixed data
Getting ready
How to do it…
Zooming and filtering
Getting ready
How to do it...
How it works…
There's more...
14. Three-dimensional Visualizations
Introduction
Three-dimensional scatter plots
Getting ready
How to do it…
How it works…
There's more…
See also...
Three-dimensional scatter plots with a regression plane
Getting ready
How to do it…
How it works…
There's more…
Three-dimensional bar charts
Getting ready
How to do it…
How it works…
Three-dimensional density plots
Getting ready
How to do it...
How it works…
15. Finalizing Graphs for Publications and Presentations
Introduction
Exporting graphs in high-resolution image formats – PNG, JPEG, BMP, and TIFF
Getting ready
How to do it...
How it works...
There's more
See also
Exporting graphs in vector formats – SVG, PDF, and PS
Getting ready
How to do it...
How it works...
There's more
Adding mathematical and scientific notations (typesetting)
Getting ready
How to do it...
How it works...
There's more
Adding text descriptions to graphs
Getting ready
How to do it...
How it works...
There's more
Using graph templates
Getting ready
How to do it...
How it works...
There's more
Choosing font families and styles under Windows, Mac OS X, and Linux
Getting ready
How to do it...
How it works...
There's more
See also
Choosing fonts for PostScripts and PDFs
Getting ready
How to do it...
How it works...
There's more
Index
← Prev
Back
Next →
← Prev
Back
Next →