Week 8 Lecture: Graphics in R - Forrest R. Stevensforreststevens.com/teaching/r/lectures/Week 08 -...

42
Week 8 Lecture: Graphics in R Introduction to Programming and Geoprocessing Using R GEOG-590-75, Spring 2015

Transcript of Week 8 Lecture: Graphics in R - Forrest R. Stevensforreststevens.com/teaching/r/lectures/Week 08 -...

Page 1: Week 8 Lecture: Graphics in R - Forrest R. Stevensforreststevens.com/teaching/r/lectures/Week 08 - Graphics in R.pdfstrings by using \n to designate new line Note

Week 8 Lecture:Graphics in R

Introduction to Programming and Geoprocessing Using R

GEOG-590-75, Spring 2015

Page 2: Week 8 Lecture: Graphics in R - Forrest R. Stevensforreststevens.com/teaching/r/lectures/Week 08 - Graphics in R.pdfstrings by using \n to designate new line Note

Week 14 Lecture:Graphics in R

Introduction to Programming and Geoprocessing Using R

GEO6938-4172GEO4938-4166

Page 3: Week 8 Lecture: Graphics in R - Forrest R. Stevensforreststevens.com/teaching/r/lectures/Week 08 - Graphics in R.pdfstrings by using \n to designate new line Note

Overview

• R can plot data and draw graphics…… but so can lots of other software.

• So why choose R?

Customizable, extensible, programmable graphics

R is permissive…

Page 4: Week 8 Lecture: Graphics in R - Forrest R. Stevensforreststevens.com/teaching/r/lectures/Week 08 - Graphics in R.pdfstrings by using \n to designate new line Note

R’s Graphics Ecosystem

• R’s Graphic Packages

• R’s 3 Distinct Chart Areas

• Script Components – High level functions

– Graphic parameters

– Low level functions

Page 5: Week 8 Lecture: Graphics in R - Forrest R. Stevensforreststevens.com/teaching/r/lectures/Week 08 - Graphics in R.pdfstrings by using \n to designate new line Note

Low Level Graphics

• R follows a “painters” model

• We can add items like we would add ink/paint

• R’s base graphics provide primitive graphics elements:

• Graphs and charts are just these elements arranged in meaningful ways

Page 6: Week 8 Lecture: Graphics in R - Forrest R. Stevensforreststevens.com/teaching/r/lectures/Week 08 - Graphics in R.pdfstrings by using \n to designate new line Note

R’s Graphics Packages

• R has several graphics subsystems:

– graphics, traditional graphics

– grid package (low level functions)

– lattice package

– ggplot2 package

• This lecture will cover the traditional, graphics system and a bit about ggplot2

Page 7: Week 8 Lecture: Graphics in R - Forrest R. Stevensforreststevens.com/teaching/r/lectures/Week 08 - Graphics in R.pdfstrings by using \n to designate new line Note

R’s Graphics Ecosystem

• R’s core graphics capabilities focus on static, 2D plots

• Possible to produce 3D and animated plots with other packages (e.g. misc3d, rgl)

grDevices

grid

lattice ggplot2

graphics

Page 8: Week 8 Lecture: Graphics in R - Forrest R. Stevensforreststevens.com/teaching/r/lectures/Week 08 - Graphics in R.pdfstrings by using \n to designate new line Note

R’s Three Distinct Chart Areas

• R’s 3 Chart Areas:1. Plot Area – within

axes2. Figure Margin Area –

for axis labels and tick mark labels

3. Outer Margin Area

• R gives User precise control over content, format of all 3 Areas– High Level Graphic

Functions– Graphic Parameters– Low Level Graphic

Functions

Based on D Kelly O’Day’s Learn R Workshop, R Charts

Page 9: Week 8 Lecture: Graphics in R - Forrest R. Stevensforreststevens.com/teaching/r/lectures/Week 08 - Graphics in R.pdfstrings by using \n to designate new line Note

Making a Graphic Scriptwith R’s Base Graphic Package

par(oma=c(2,2,2,2)); par(mar=c(3,3,1,1))

plot(x_data, y_data, main = "My Chart Title", type = "b",

xlim = c(0,11), ylim = c(0,11), xlab ="X",

ylab = "Y", pch=16, col = "red", bty = "n",

xaxs="i", yaxs = "i", las=1)

text(2,7, "my note", col = "blue" )

# R Script to produce scatter

chart

x_data <- ...

y_data <- ...

## Graphic parameters

par( )

## High level plot function

plot( )

## Low level function

text( )

Graphic Parameters 70 GPs defaults set w/

par()

High Level GraphicFunction Call

Use GP defaultsor

w/ argument

Low Level GraphicFunction Call

Use GP defaults or

w/ argument

Page 10: Week 8 Lecture: Graphics in R - Forrest R. Stevensforreststevens.com/teaching/r/lectures/Week 08 - Graphics in R.pdfstrings by using \n to designate new line Note

par(oma=c(2,2,2,2))

par(mar=c(3,3,1,1))

plot(x_data, y_data,

main = "My Chart Title",

type = "b", xlim = (0,11),

ylim = c(0,11), xlab ="X",

ylab = "Y", pch=16,

col = "red", bty = "n",

xaxs="i", yaxs = "i",

las=1)

text(2,7, "my note", col = "blue" )

Making a Graphic Scriptwith R’s Base Graphic Package

Page 11: Week 8 Lecture: Graphics in R - Forrest R. Stevensforreststevens.com/teaching/r/lectures/Week 08 - Graphics in R.pdfstrings by using \n to designate new line Note

High Level Graphic Functions

Type R function()

Bar Chart barplot()

Box & Whisker Plot boxplot()

Dot Plot dotchartt()

Histogram hist()

Scatter Plot plot()

Strip Chart stripchart()

High level functions produce complete charts…

We’re focusing on plot() and its "low" level functions, graphic parameters…

Page 12: Week 8 Lecture: Graphics in R - Forrest R. Stevensforreststevens.com/teaching/r/lectures/Week 08 - Graphics in R.pdfstrings by using \n to designate new line Note

Low Level Plot FunctionsAdd graphic content to current plot

grid(nx, ny) Add grid lines to current plot. NA stop grid in corresponding direction

axis(side n,) Add axis at side n to current plot

box(which=, )Add box around current plot, figure or outer margin area depending on which specified

legend Add legend to current plot

arrows(x,y)

lines(x, y)

points(x,y)

Add arrow line, line or points to current plot. type = can be used to specify style ("p","b", "l", etc)

abline(a,b)

abline(h= or v=)

Add line to current plot. a is intercept, b is slope.

h/v for horizontal/ vertical line

segments(x0,x1,y0, y1) Add line segment(s) between pairs of points

polygon(x,y) Add polygon defined by vectors x and y

text(x,y, "note") Add text to current plot at x & y

Page 13: Week 8 Lecture: Graphics in R - Forrest R. Stevensforreststevens.com/teaching/r/lectures/Week 08 - Graphics in R.pdfstrings by using \n to designate new line Note

Graphic Parameters (GP)• R has over 70 Graphic Parameters (GP)• Each GP has:

– name: col =– value: "red"

• Default values set at start of an R session

• To get par() values:– par() lists all GPs with current value– par("GP_name") gives current value

for specific GP

• User can change GP values:– Global:

par("col" = "red")

– Local: plot(x,y, col="red")

> par("col")

[1] "black"

Page 14: Week 8 Lecture: Graphics in R - Forrest R. Stevensforreststevens.com/teaching/r/lectures/Week 08 - Graphics in R.pdfstrings by using \n to designate new line Note

Essential Graphical Parametersadj= Text string justification: 0=left, 0.5=centered, 1=right

ann= T or F controls plot annotation

bg= Background color

bty= Type of box around plot: "n"=none, "l" = x & y, "o" = full

cex= Magnification ratio for text relative to default point size

col= Color specification. R accepts "red", "blue", "dark grey", etc names for 657 colors

las= Style of tick mark labels: 0=parallel to axis, 1 =always horizontal, 3=always vertical

lty= Line type: 0=blank, 1=solid, 2=dashed, 3=dotted, 4=dotdash, 5=longdash, 6=twodash

lwd= Line width, default is 1.

* mar=, oma= Vector c(b,l,t,r) that sets number of lines for margin and outer margin areas by axis #

* mfcol=,

mfrow=Vector c(nr,nc) to specify multiple plots. mfcol draws by columns, mfrow by row

pch= Integer specifying a symbol to be used in plotting points

* ps= Point size of text, not symbols

* pty= Plot region: s=square, m=maximum

srt= String rotation in degrees

* xaxs=, yaxs= Style of axis: "r" = offset of x & y to prevent points overplotting axis, "i" = no offset

* These parameters must be set with call to par().

Page 15: Week 8 Lecture: Graphics in R - Forrest R. Stevensforreststevens.com/teaching/r/lectures/Week 08 - Graphics in R.pdfstrings by using \n to designate new line Note

pch = Plot Characters Graphic Parameter

• R has 25 plotting characters

• pch = specifies plot character

• Characters 19 – 20 can be filled with selected color

o 19 – Solid circle

o 20 – Bullet circle

• Characters 21: 25 can have selected fill and border colors

bg = Controls Border color

col= Controls fill

Page 16: Week 8 Lecture: Graphics in R - Forrest R. Stevensforreststevens.com/teaching/r/lectures/Week 08 - Graphics in R.pdfstrings by using \n to designate new line Note

lty= Line Type Graphic Parameter

• R has 6 line types

• lty = specifies the line type

• lty= can be specified as integer or character string:

0 – "blank"

1 – "solid"

2 – "dashed"

3 – "dotted"

4 – "dotdash"

5 – "longdash"

6 – "twodash"

Page 17: Week 8 Lecture: Graphics in R - Forrest R. Stevensforreststevens.com/teaching/r/lectures/Week 08 - Graphics in R.pdfstrings by using \n to designate new line Note

plot() Function Argumentsx,y

y~xVectors for x and y values to be plotted

type=

type = "p" – individual points

type = "l" – line

type = "b" – points connected with lines

type = "h" – vertical lines from 0

type = "s" – step chart

main = " "

sub = " "

Figure title top of plot, large font

Sub title – below X axis, smaller font

xlab = " "

ylab = " " X and Y axis titles

ann= T or F Should default annotation be included

axes = T or F Set to F when you want custom axis

xlim=c( x1, x2)

ylim=c(y1, y2)Limits of plot for X and Y axes

plot(x,y, type="?",

main = "??",

sub = "??",

xlab ="??",

ylab ="??", ann = ?,

axes = ?,

xlim = c(x1,x2),

ylim = c(y1,y2))

or

plot(y ~ x, data = "??",

type="?", main="??",

sub = "??",

xlab="??",

ylab ="??", ann = ?,

axes = ?,

xlim = c(x1,x2),

ylim = c(y1,y2))

Page 18: Week 8 Lecture: Graphics in R - Forrest R. Stevensforreststevens.com/teaching/r/lectures/Week 08 - Graphics in R.pdfstrings by using \n to designate new line Note

plot() Function Defaults## Ex_Scr_4_1_default_plot.R ###################

##Script to produce default XY plot()

## STEP 1: SETUP - Source File

rm(list=ls())

par(oma=c(2,1,0,1))

script = "C:/Learn_R/Mod_4_R_Charts/Ex_Scr_4_1_default_plot.R"

## STEP 2: READ DATA

y_data <- c(0,1,2,3,4,5,6,7,8,9,10,9,8,7,6,5,4,3,2,1,0)

x_data <- seq(0:20)

## STEP 3: MANIPULATE DATA

## STEP 4: PRODUCE CHART - REPORT

plot(x_data,y_data, main = "plot() Defaults ")

## Outer Margin annotation

my_date <- format(Sys.time(), "%m/%d/%y")

mtext(script, side = 1, line = .75, cex=0.7, outer = T, adj = 0)

mtext(my_date, side = 1, line =.75, cex = 0.7, outer = T, adj = 1)

Page 19: Week 8 Lecture: Graphics in R - Forrest R. Stevensforreststevens.com/teaching/r/lectures/Week 08 - Graphics in R.pdfstrings by using \n to designate new line Note

plot() Function Defaults

Page 20: Week 8 Lecture: Graphics in R - Forrest R. Stevensforreststevens.com/teaching/r/lectures/Week 08 - Graphics in R.pdfstrings by using \n to designate new line Note

Adding Text within Margin Area

mtext( "note", side = , line =

, outer = F, adj = 0, cex = 1,

col = "red")

• "note" – text to be added to margin area

• side – side of plot to place text(1= bottom, 2= left, 3= top, 4=right)

• line – line of margin to place text, starting at 0, counting outwards

• outer – use outer area (T or F)

• adj – text alignment, 0 = left, 0.5= center, 1 = right

• cex - font adjustment factor

• col - color

Axis

Sides

1

2

3

4

Axis Numbering Convention

Page 21: Week 8 Lecture: Graphics in R - Forrest R. Stevensforreststevens.com/teaching/r/lectures/Week 08 - Graphics in R.pdfstrings by using \n to designate new line Note

Improving plot() Function Defaults

plot(x_data,y_data,

main = "plot() Defaults" )

plot(x_data,y_data,

main = "plot() Default Improvements",

type = "b", col = "red", bty = "n",

xaxs="i", yaxs = "i", las=1,

xlim = c(0,25), ylim = c(0,12),

xlab = "X", ylab = "Y" )

Page 22: Week 8 Lecture: Graphics in R - Forrest R. Stevensforreststevens.com/teaching/r/lectures/Week 08 - Graphics in R.pdfstrings by using \n to designate new line Note

Working With R Colors

• Users can specify colors by name; R has 657 colors

– "red"

– "blue"

– "darkgreen"

• To get list of R colors:

>colors()

• col = most common way to specify color for lines, points, text

• Alternatives: rgb() and hsv()

• Color Conversions:

– col2rgb()

– convertColor()

Page 23: Week 8 Lecture: Graphics in R - Forrest R. Stevensforreststevens.com/teaching/r/lectures/Week 08 - Graphics in R.pdfstrings by using \n to designate new line Note

plot() type argument type=?• "p" for points

• "b" for both

• "o" for both ‘overplotted’

• "l" for lines

• "c" for the lines part alone of "b"

• "h" for high-density vertical lines

• "s" for h/v stair steps

• "S" for v/h stair steps

• "n" for no plotting

Page 24: Week 8 Lecture: Graphics in R - Forrest R. Stevensforreststevens.com/teaching/r/lectures/Week 08 - Graphics in R.pdfstrings by using \n to designate new line Note

Example Scatter plot

###################

##Script to produce scatter plot

## STEP 1: SETUP - Source File

par(oma=c(2,1,0,1))

## STEP 2: READ DATA

x_data <- seq(0,10*pi,0.1*pi)

y_data <- sin(x_data)

plot(x_data,y_data,type = "l")

Page 25: Week 8 Lecture: Graphics in R - Forrest R. Stevensforreststevens.com/teaching/r/lectures/Week 08 - Graphics in R.pdfstrings by using \n to designate new line Note

Working With Text

Text Additions:

– main= argument to add chart title in figure margin at top

– sub= argument to add subtitle below X axis

– text() – low level function to add text in plot area

– mtext() – low level function to add text in margin and outer areas

• Size: par(ps=10)

• Magnification: cex = 0.85

• Color: col="red" (657 named color choices)

• font= 1-4 (regular, bold, italic, bold italic)

• family= ("sans", "serif", "mono")

• Alignment: adj = 0,.5,1(left,center, right)

• Rotation: srt=

Page 26: Week 8 Lecture: Graphics in R - Forrest R. Stevensforreststevens.com/teaching/r/lectures/Week 08 - Graphics in R.pdfstrings by using \n to designate new line Note

Adding text string in Plot Areatext () Function

text( x, y, "note", pos =0, cex = 1,

col = "red", srt = 45)

x,y – plot area coordinates where text should be placed

"note" – text to be added to plot

pos – position of text with respect to x, y coordinates. Default is centered on point.

cex - font magnification factor

col - color

srt – text rotation - degrees

• User can construct multi-line text

strings by using \n to designate new line

Note <- "This is an example \n

of a multi-line note "

\n for Multi-line Text

\" to add quote marks to text string

• Text strings designated by " " marks

• User can embed quote marks within text string by using \" to have R not treat mark as begin/end of text string

Note <- "This is an example of using

\"quote marks\" within text string"

Page 27: Week 8 Lecture: Graphics in R - Forrest R. Stevensforreststevens.com/teaching/r/lectures/Week 08 - Graphics in R.pdfstrings by using \n to designate new line Note

text() font and family

• font= font type for plot text=1 Standard =2 Bold=3 Italic=4 Bold and italic

• Use for other figure text– font.axis; font.lab– font.main; font.sub

• family = controls font family

= "sans"

= "serif"

= "mono"

Page 28: Week 8 Lecture: Graphics in R - Forrest R. Stevensforreststevens.com/teaching/r/lectures/Week 08 - Graphics in R.pdfstrings by using \n to designate new line Note

Adding Lines in Plot Areax <- 0:100

y <- x^2

x_pts <- c(15, 35, 35, 15, 15)

y_pts <- c(8300, 8300, 6500, 6500,8300)

plot(x,y, type = "n",

main="Add Lines, Points, Arrows Examples")

points(x, y,col = "black", lty=1, type = "l")

grid(col="lightgrey", lty=1)

abline(h=2500, col="red")

abline(v=50, col = "blue")

arrows(65,8400, 85,8400, code=3,

col="orange", length = 0.1)

lines(x_pts, y_pts, lty=1, col = "green")

points(x_pts,y_pts, type = "p",

col ="red",pch=19)

Page 29: Week 8 Lecture: Graphics in R - Forrest R. Stevensforreststevens.com/teaching/r/lectures/Week 08 - Graphics in R.pdfstrings by using \n to designate new line Note

Plot Box and Axis Styles

• Plot Box & Axis Options

– Box type

• bty="n"

• bty="o"

– Axes

• axes = T or F

– Axis Offset:

• xaxs= "i" or "r"

• yaxs = "i" or "r"

– Axis 3 & 4 tick marks

• Axis(n, tick=T)

Page 30: Week 8 Lecture: Graphics in R - Forrest R. Stevensforreststevens.com/teaching/r/lectures/Week 08 - Graphics in R.pdfstrings by using \n to designate new line Note

Adding Mathematical Expressions

Page 31: Week 8 Lecture: Graphics in R - Forrest R. Stevensforreststevens.com/teaching/r/lectures/Week 08 - Graphics in R.pdfstrings by using \n to designate new line Note

Basic graphics functions in R

abline Add Straight Lines to a Plot

arrows Add Arrows to a Plot

assocplot Association Plots

axTicks Compute Axis Tickmark Locations

axis Add an Axis to a Plot

axis.POSIXct Date and Date-time Plotting Functions

barplot Bar Plots

box Draw a Box around a Plot

boxplot Box Plots

bxp Draw Box Plots from Summaries

cdplot Conditional Density Plots

contour Display Contours

coplot Conditioning Plots

curve Draw Function Plots

dotchart Cleveland Dot Plots

filled.contour Level (Contour) Plots

fourfoldplot Fourfold Plots

frame Create / Start a New Plot Frame

grid Add Grid to a Plot

hist Histograms

hist.POSIXt Histogram of a Date or Date-Time Object

Page 32: Week 8 Lecture: Graphics in R - Forrest R. Stevensforreststevens.com/teaching/r/lectures/Week 08 - Graphics in R.pdfstrings by using \n to designate new line Note

Basic graphics functions in R

identify Identify Points in a Scatter Plot

image Display a Color Image

layout Specifying Complex Plot Arrangements

legend Add Legends to Plots

lines Add Connected Line Segments to a Plot

locator Graphical Input

matplot Plot Columns of Matrices

mosaicplot Mosaic Plots

mtext Write Text into the Margins of a Plot

pairs Scatterplot Matrices

panel.smooth Simple Panel Plot

par Set or Query Graphical Parameters

persp Perspective Plots

pie Pie Charts

Page 33: Week 8 Lecture: Graphics in R - Forrest R. Stevensforreststevens.com/teaching/r/lectures/Week 08 - Graphics in R.pdfstrings by using \n to designate new line Note

Basic graphics functions in R

points Add Points to a Plot

polygon Polygon Drawing

rect Draw One or More Rectangles

rug Add a Rug to a Plot

screen Creating and Controlling Multiple Screens on a

Single Device

segments Add Line Segments to a Plot

spineplot Spine Plots and Spinograms

stars Star (Spider/Radar) Plots and Segment Diagrams

stem Stem-and-Leaf Plots

stripchart 1-D Scatter Plots

strwidth Plotting Dimensions of Character Strings and

Math Expressions

sunflowerplot Produce a Sunflower Scatter Plot

symbols Draw Symbols (Circles, Squares, Stars,

Thermometers, Boxplots) on a Plot

text Add Text to a Plot

title Plot Annotation

xinch Graphical Units

Page 34: Week 8 Lecture: Graphics in R - Forrest R. Stevensforreststevens.com/teaching/r/lectures/Week 08 - Graphics in R.pdfstrings by using \n to designate new line Note

Basic graphics functions in R

Generic function plot and its class-specific methods:

plot Generic X-Y Plotting

plot.data.frame Plot Method for Data Frames

plot.default The Default Scatterplot Function

plot.design Plot Univariate Effects of a 'Design' or Model

plot.factor Plotting Factor Variables

plot.formula Formula Notation for Scatterplots

plot.histogram Plot Histograms

plot.table Plot Methods for 'table' Objects

plot.window Set up World Coordinates for Graphics Window

plot.xy Basic Internal Plot Function

Page 35: Week 8 Lecture: Graphics in R - Forrest R. Stevensforreststevens.com/teaching/r/lectures/Week 08 - Graphics in R.pdfstrings by using \n to designate new line Note

ggplot2

• High level plotting functionality

• Provides a graphical “language” for building very nice figures

• Has a good book out now explaining the philosophy behind it:

http://had.co.nz/ggplot2/

Page 36: Week 8 Lecture: Graphics in R - Forrest R. Stevensforreststevens.com/teaching/r/lectures/Week 08 - Graphics in R.pdfstrings by using \n to designate new line Note

ggplot2 Example

data(mpg)

ggplot(mpg, aes(displ, hwy))+

geom_point()+

geom_line(aes(color = factor(cyl)))

Page 37: Week 8 Lecture: Graphics in R - Forrest R. Stevensforreststevens.com/teaching/r/lectures/Week 08 - Graphics in R.pdfstrings by using \n to designate new line Note
Page 38: Week 8 Lecture: Graphics in R - Forrest R. Stevensforreststevens.com/teaching/r/lectures/Week 08 - Graphics in R.pdfstrings by using \n to designate new line Note

ggplot2 Examples

p <- ggplot(mpg, aes(displ, hwy))

p + geom_point() + stat_smooth()

Page 39: Week 8 Lecture: Graphics in R - Forrest R. Stevensforreststevens.com/teaching/r/lectures/Week 08 - Graphics in R.pdfstrings by using \n to designate new line Note

ggplot2 Examples

By default, stat_smooth() has added a loess line with the standard error represented by a semi-transparent ribbon. You could also specify the method to use to add a different smoothing line:

p + geom_point() + stat_smooth(method = "lm")

library(MASS)

p + geom_point() + stat_smooth(method = "rlm")

Page 40: Week 8 Lecture: Graphics in R - Forrest R. Stevensforreststevens.com/teaching/r/lectures/Week 08 - Graphics in R.pdfstrings by using \n to designate new line Note

ggplot2 Shortcut

• qplot() is the “simple” version of ggplot() and is very easy to use:

qplot(x=ShotDist, geom="histogram",

fill=as.factor(DistToPin),

main="Distribution of Accurate Shot

Distances (< 20 yds.) by Shot Distance",

binwidth=10, data=subset(raw_data,

BallToPinDist < 20))

Page 41: Week 8 Lecture: Graphics in R - Forrest R. Stevensforreststevens.com/teaching/r/lectures/Week 08 - Graphics in R.pdfstrings by using \n to designate new line Note

Distribution of Accurate Shot Distances (< 20 yds.) by Shot Distance

ShotDist

co

un

t

0

2

4

6

8

100 120 140 160 180

as.factor(DistToPin)

125

150

175

Page 42: Week 8 Lecture: Graphics in R - Forrest R. Stevensforreststevens.com/teaching/r/lectures/Week 08 - Graphics in R.pdfstrings by using \n to designate new line Note

For further information:• The R Graphics Cookbook

http://www.cookbook-r.com/Graphs/

– Another great R resource: http://www.cookbook-r.com/

• "ggplot2: Elegant Graphics for Data Analysis"http://ggplot2.org/

• "R Graphics, Second Edition"http://www.stat.auckland.ac.nz/~paul/RG2e/

• “Learn R Toolkit”http://chartsgraphs.wordpress.com/learnr-toolkit/

• "Lattice: Multivariate Data Visualization with R"http://lmdvr.r-forge.r-project.org/

• The Graphics CRAN Task Viewhttp://cran.r-project.org/web/views/Graphics.html