combining scales
play

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


  1. Combining scales DATA VISU AL IZATION W ITH L ATTIC E IN R Deepa y an Sarkar Associate Professor , Indian Statistical Instit u te

  2. Chapter goals Control and annotation of a x is limits Control v is u al appearance ( graphical parameters ) DATA VISUALIZATION WITH LATTICE IN R

  3. The USMortalit y dataset 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

  4. The USMortalit y dataset 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

  5. Leading ca u ses of death : dot plots dotplot(Cause ~ Rate | Sex + Status, USMortality, as.table = TRUE) DATA VISUALIZATION WITH LATTICE IN R

  6. Defa u lt a x is limits Common to all panels Chosen to co v er the data range This is u sef u l beca u se common limits make panels easier to compare w e sa v e space b y not dra w ing a x es for each panel DATA VISUALIZATION WITH LATTICE IN R

  7. Leading ca u ses of death , again dotplot(Cause ~ Rate | Sex + Status, USMortality, as.table = TRUE) DATA VISUALIZATION WITH LATTICE IN R

  8. Controlling a x is comp u tation Controlled u sing the scales arg u ment . List w ith named s u b - components Most common s u b - component : relation relation = "same" : common limits ( defa u lt ) relation = "free" : independent limits relation = "sliced" : di � erent w ith same range DATA VISUALIZATION WITH LATTICE IN R

  9. Controlling a x is comp u tation dotplot(Cause ~ Rate | Sex + Status, USMortality, as.table = TRUE, scales = list(x = list(relation = "free"))) DATA VISUALIZATION WITH LATTICE IN R

  10. Let ' s practice ! DATA VISU AL IZATION W ITH L ATTIC E IN R

  11. Logarithmic scales DATA VISU AL IZATION W ITH L ATTIC E IN R Deepa y an Sarkar Associate Professor , Indian Statistical Instit u te

  12. Gro u ping b y stat u s dotplot(Cause ~ Rate | Sex, data = USMortality, groups = Status, auto.key = TRUE) DATA VISUALIZATION WITH LATTICE IN R

  13. Logarithmic scales dotplot(Cause ~ log(Rate) | Sex, data = USMortality, groups = Status, auto.key = list(columns = 2)) DATA VISUALIZATION WITH LATTICE IN R

  14. Logarithmic scales dotplot(Cause ~ Rate | Sex, USMortality, groups = Status, scales = list(x = list(log = 2)), auto.key = list(columns = 2)) DATA VISUALIZATION WITH LATTICE IN R

  15. Logarithmic scales dotplot(Cause ~ Rate | Sex, USMortality, groups = Status, scales = list(x = list(log = 2, equispaced.log = FALSE)), auto.key = list(columns = 2)) DATA VISUALIZATION WITH LATTICE IN R

  16. Let ' s practice ! DATA VISU AL IZATION W ITH L ATTIC E IN R

  17. Graphical parameters DATA VISU AL IZATION W ITH L ATTIC E IN R Deepa y an Sarkar Associate Professor , Indian Statistical Instit u te

  18. Graphical parameters T w o standard approaches in base graphics : par() f u nction to make persistent changes optional arg u ments in f u nction calls Analogo u s approaches a v ailable in la � ice . DATA VISUALIZATION WITH LATTICE IN R

  19. Using a global theme library(latticeExtra) new.theme <- ggplot2like() old.theme <- trellis.par.get() 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

  20. Using a global theme DATA VISUALIZATION WITH LATTICE IN R

  21. Making minor changes dotplot(Cause ~ Rate | Sex, USMortality, groups = Status, pch = 15, col = c("red", "blue"), scales = list(x = list(log = 2, equispaced.log = FALSE))) DATA VISUALIZATION WITH LATTICE IN R

  22. Let ' s practice ! DATA VISU AL IZATION W ITH L ATTIC E IN R

  23. Using simpleTheme () DATA VISU AL IZATION W ITH L ATTIC E IN R Deepa y an Sarkar Associate Professor , Indian Statistical Instit u te

  24. Plotting s y mbols 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

  25. Changing s y mbol and color 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

  26. Using simpleTheme () 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 VISUALIZATION WITH LATTICE IN R

  27. Let ' s practice ! DATA VISU AL IZATION W ITH L ATTIC E IN R

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend