Managing v is u al comple x it y DATA VISU AL IZATION IN R Ron - - PowerPoint PPT Presentation

managing v is u al comple x it y
SMART_READER_LITE
LIVE PREVIEW

Managing v is u al comple x it y DATA VISU AL IZATION IN R Ron - - PowerPoint PPT Presentation

Managing v is u al comple x it y DATA VISU AL IZATION IN R Ron Pearson Instr u ctor Usef u l v is u ali z ations sho w u s details DATA VISUALIZATION IN R Usef u l v is u ali z ations sho w u s details DATA VISUALIZATION IN R Usef u l v is u


slide-1
SLIDE 1

Managing visual complexity

DATA VISU AL IZATION IN R

Ron Pearson

Instructor

slide-2
SLIDE 2

DATA VISUALIZATION IN R

Useful visualizations show us details

slide-3
SLIDE 3

DATA VISUALIZATION IN R

Useful visualizations show us details

slide-4
SLIDE 4

DATA VISUALIZATION IN R

Useful visualizations don't show too many details

slide-5
SLIDE 5

DATA VISUALIZATION IN R

Multiple scatterplots on one set of axes: matplot()

library(MASS) matplot(Cars93$Horsepower, Cars93[, c("MPG.city", "MPG.highway")], xlab = "Horsepower", ylab = "Gas mileages") legend("topright", pch = c("1", "2"), col = c("black", "red"), legend = c("MPG.city", "MPG.highway"))

slide-6
SLIDE 6

DATA VISUALIZATION IN R

library(MASS) matplot(Cars93$Horsepower, Cars93[, c("MPG.city", "MPG.highway")], xlab = "Horsepower", ylab = "Gas mileages") legend("topright", pch = c("1", "2"), col = c("black", "red"), legend = c("MPG.city", "MPG.highway"))

slide-7
SLIDE 7

Let's practice!

DATA VISU AL IZATION IN R

slide-8
SLIDE 8

Creating plot arrays with the mfrow parameter

DATA VISU AL IZATION IN R

Ron Pearson

Instructor

slide-9
SLIDE 9

DATA VISUALIZATION IN R

Multiple plot arrays

Dierences between datasets Dierent views of the same dataset Similarities between datasets Related views of same dataset

slide-10
SLIDE 10

DATA VISUALIZATION IN R

slide-11
SLIDE 11

DATA VISUALIZATION IN R

Set up plot array with R rows and C columns

library(MASS) par(mfrow = c(2, 3)) # Set up a 2-row, 3-column array plot(UScereal$fat, UScereal$calories) title("Calories vs. fat") plot(UScereal$carbo, UScereal$calories) title("Calories vs. carbo") plot(UScereal$sugars, UScereal$calories) title("Calories vs. sugars") plot(UScereal$fat, UScereal$fibre) title("Fibre vs. fat") plot(UScereal$carbo, UScereal$fibre) title("Fibre vs. carbo") plot(UScereal$sugars, UScereal$fibre) title("Fibre vs. sugars")

slide-12
SLIDE 12

DATA VISUALIZATION IN R

slide-13
SLIDE 13

DATA VISUALIZATION IN R

Creating side-by-side plot pairs

library(MASS) par(mfrow = c(1, 2)) plot(density(geyser$duration), main = "Duration") plot(density(geyser$waiting), main = "Waiting time")

slide-14
SLIDE 14

DATA VISUALIZATION IN R

Creating side-by-side plot pairs

library(MASS) par(mfrow = c(1, 2)) par(pty = "s") plot(density(geyser$duration), main = "Duration") plot(density(geyser$waiting), main = "Waiting time")

slide-15
SLIDE 15

Let's practice!

DATA VISU AL IZATION IN R

slide-16
SLIDE 16

Creating plot arrays with the layout() function

DATA VISU AL IZATION IN R

Ron Pearson

Instructor

slide-17
SLIDE 17

DATA VISUALIZATION IN R

layout() uses a matrix to define the plot array

rowA <- c(1, 1, 1) rowB <- c(2, 0, 3) layoutVector <- c(rowA, rowA, rowB) layoutMatrix <- matrix(layoutVector, byrow = TRUE, nrow = 3) layoutMatrix [,1] [,2] [,3] [1,] 1 1 1 [2,] 1 1 1 [3,] 2 0 3

slide-18
SLIDE 18

DATA VISUALIZATION IN R

layout.show() shows the structure of the array

layout(layoutMatrix) # Use the matrix constructed previously layout.show(n = 3) See layout of all three plots

slide-19
SLIDE 19

DATA VISUALIZATION IN R

layout() helps create non-rectangular plot arrays

slide-20
SLIDE 20

DATA VISUALIZATION IN R

layout() helps create non-rectangular plot arrays

rowA <- c(1, 1, 1) rowB <- c(2, 0, 3) layoutVector <- c(rowA, rowA, rowB) layoutMatrix <- matrix(layoutVector, byrow = TRUE, nrow = 3) layout(layoutMatrix) library(MASS) plot(UScereal$sugars, UScereal$calories, pch = 15, col = "magenta") title("Long, skinny scatterplot across the top of the array") plot(density(UScereal$sugars), main = "Small left-hand plot: \n Sugars density") plot(density(UScereal$calories), main = "Small right-hand plot: \n Calories density")

slide-21
SLIDE 21

Let's practice!

DATA VISU AL IZATION IN R