Combining scales
DATA VISU AL IZATION W ITH L ATTIC E IN R
Deepayan Sarkar
Associate Professor, Indian Statistical Institute
Combining scales DATA VISU AL IZATION W ITH L ATTIC E IN R Deepa - - PowerPoint PPT Presentation
Combining scales DATA VISU AL IZATION W ITH L ATTIC E IN R Deepa y an Sarkar Associate Professor , Indian Statistical Instit u te Chapter goals Control and annotation of a x is limits Control v is u al appearance ( graphical parameters ) DATA
DATA VISU AL IZATION W ITH L ATTIC E IN R
Deepayan Sarkar
Associate Professor, Indian Statistical Institute
DATA VISUALIZATION WITH LATTICE IN R
Control and annotation of axis limits Control visual appearance (graphical parameters)
DATA VISUALIZATION WITH LATTICE IN R
library(lattice); str(USMortality) 'data.frame': 40 obs. of 5 variables: $ Status: Factor w/ 2 levels "Rural","Urban": 2 1 2 1 2 1 2 1 2 1 $ Sex : Factor w/ 2 levels "Female","Male": 2 2 1 1 2 2 1 1 2 2 $ Cause : Factor w/ 10 levels "Alzheimers","Cancer",..: 6 6 6 6 2 $ Rate : num 210 243 132 155 196 ... $ SE : num 0.2 0.6 0.2 0.4 0.2 0.5 0.2 0.4 0.1 0.3 ...
DATA VISUALIZATION WITH LATTICE IN R
levels(USMortality$Cause) [1] "Alzheimers" "Cancer" [3] "Cerebrovascular diseases" "Diabetes" [5] "Flu and pneumonia" "Heart disease" [7] "Lower respiratory" "Nephritis" [9] "Suicide" "Unintentional injuries" USMortality <- dplyr::mutate(USMortality, Cause = reorder(Cause, Rat
DATA VISUALIZATION WITH LATTICE IN R
dotplot(Cause ~ Rate | Sex + Status, USMortality, as.table = TRUE)
DATA VISUALIZATION WITH LATTICE IN R
Common to all panels Chosen to cover the data range This is useful because common limits make panels easier to compare we save space by not drawing axes for each panel
DATA VISUALIZATION WITH LATTICE IN R
dotplot(Cause ~ Rate | Sex + Status, USMortality, as.table = TRUE)
DATA VISUALIZATION WITH LATTICE IN R
Controlled using the scales argument. List with named sub-components Most common sub-component: relation
relation = "same" : common limits (default) relation = "free" : independent limits relation = "sliced" : dierent with same range
DATA VISUALIZATION WITH LATTICE IN R
dotplot(Cause ~ Rate | Sex + Status, USMortality, as.table = TRUE, scales = list(x = list(relation = "free")))
DATA VISU AL IZATION W ITH L ATTIC E IN R
DATA VISU AL IZATION W ITH L ATTIC E IN R
Deepayan Sarkar
Associate Professor, Indian Statistical Institute
DATA VISUALIZATION WITH LATTICE IN R
dotplot(Cause ~ Rate | Sex, data = USMortality, groups = Status, auto.key = TRUE)
DATA VISUALIZATION WITH LATTICE IN R
dotplot(Cause ~ log(Rate) | Sex, data = USMortality, groups = Status, auto.key = list(columns = 2))
DATA VISUALIZATION WITH LATTICE IN R
dotplot(Cause ~ Rate | Sex, USMortality, groups = Status, scales = list(x = list(log = 2)), auto.key = list(columns = 2))
DATA VISUALIZATION WITH LATTICE IN R
dotplot(Cause ~ Rate | Sex, USMortality, groups = Status, scales = list(x = list(log = 2, equispaced.log = FALSE)), auto.key = list(columns = 2))
DATA VISU AL IZATION W ITH L ATTIC E IN R
DATA VISU AL IZATION W ITH L ATTIC E IN R
Deepayan Sarkar
Associate Professor, Indian Statistical Institute
DATA VISUALIZATION WITH LATTICE IN R
Two standard approaches in base graphics:
par() function to make persistent changes
Analogous approaches available in laice.
DATA VISUALIZATION WITH LATTICE IN R
library(latticeExtra) new.theme <- ggplot2like()
trellis.par.set(new.theme) dotplot(Cause ~ Rate | Sex, data = USMortality, groups = Status, auto.key = list(columns = 2), between = list(x = 0.5), scales = list(x = list(log = 2, equispaced.log = FALSE))) trellis.par.set(old.theme)
DATA VISUALIZATION WITH LATTICE IN R
DATA VISUALIZATION WITH LATTICE IN R
dotplot(Cause ~ Rate | Sex, USMortality, groups = Status, pch = 15, col = c("red", "blue"), scales = list(x = list(log = 2, equispaced.log = FALSE)))
DATA VISU AL IZATION W ITH L ATTIC E IN R
DATA VISU AL IZATION W ITH L ATTIC E IN R
Deepayan Sarkar
Associate Professor, Indian Statistical Institute
DATA VISUALIZATION WITH LATTICE IN R
dotplot(Cause ~ Rate | Sex, USMortality, groups = Status, auto.key = list(columns = 2), scales = list(x = list(log = 2, equispaced.log = FALSE)))
DATA VISUALIZATION WITH LATTICE IN R
dotplot(Cause ~ Rate | Sex, USMortality, groups = Status, auto.key = list(columns = 2), pch = 16, col = c("red","blue"), scales = list(x = list(log = 2, equispaced.log = FALSE)))
DATA VISUALIZATION WITH LATTICE IN R
dotplot(Cause ~ Rate | Sex, USMortality, groups = Status, auto.key = list(columns = 2), par.settings = simpleTheme(pch = 16, col = c("red","blue")), scales = list(x = list(log = 2, equispaced.log = FALSE)))
DATA VISU AL IZATION W ITH L ATTIC E IN R