+ - 0:00:00
Notes for current slide
Notes for next slide

ASP 460 2.0 Special Topics in Statistics

Interactive graphics

Thiyanga Talagala

2020-06-26

1 / 26

Data

# A tibble: 6 x 7
species island culmen_length culmen_depth flipper_length body_mass sex
<fct> <fct> <dbl> <dbl> <int> <int> <fct>
1 Adelie Torgersen 39.1 18.7 181 3750 male
2 Adelie Torgersen 39.5 17.4 186 3800 female
3 Adelie Torgersen 40.3 18 195 3250 female
4 Adelie Torgersen 36.7 19.3 193 3450 female
5 Adelie Torgersen 39.3 20.6 190 3650 male
6 Adelie Torgersen 38.9 17.8 181 3625 female
species island culmen_length culmen_depth flipper_length
Adelie :146 Biscoe :163 Min. :32.10 Min. :13.10 Min. :172
Chinstrap: 68 Dream :123 1st Qu.:39.50 1st Qu.:15.60 1st Qu.:190
Gentoo :119 Torgersen: 47 Median :44.50 Median :17.30 Median :197
Mean :43.99 Mean :17.16 Mean :201
3rd Qu.:48.60 3rd Qu.:18.70 3rd Qu.:213
Max. :59.60 Max. :21.50 Max. :231
body_mass sex
Min. :2700 female:165
1st Qu.:3550 male :168
Median :4050
Mean :4207
3rd Qu.:4775
Max. :6300
2 / 26

Static graphic

3 / 26

Interactive graphics

  • allows the use to interact with the graphical information presented on the display.

  • Cross filtering

    • Zoom by selecting an area of interest

    • Hover the line to get exact information.

4 / 26

Interactive plot

1701801902002102202303000400050006000
AdelieChinstrapGentooflipper_lengthbody_massspecies
5 / 26

Interactive plot (cont.)

30004000500060000.00000.00050.00100.001530004000500060003000400050006000
femalemalebody_massdensityAdelieChinstrapGentoosex
6 / 26

plotly

powered by the JavaScript library plotly.js

7 / 26

Introduction to plot_ly():

  • Mapping variables: Instead of aes use ~
8 / 26

Introduction to plot_ly()

180200220250030003500400045005000550060006500
flipper_lengthbody_mass
9 / 26

Introduction to plot_ly()

180200220250030003500400045005000550060006500
flipper_lengthbody_mass
10 / 26

Introduction to plot_ly()

  • plotly finds a suitable geometric representation for us.

  • Users can also define geometries.

  • Functions to encode data

    • color: map each level to a different colour
    • colors: specify a range of colours
    • stroke
    • span
    • symbol
    • linetype
11 / 26

color argument

180200220250030003500400045005000550060006500
AdelieChinstrapGentooflipper_lengthbody_mass
12 / 26

colors argument

180200220250030003500400045005000550060006500
4050culmen_lengthflipper_lengthbody_mass

Default

180200220250030003500400045005000550060006500
4050culmen_lengthflipper_lengthbody_mass

colors="Accent"

13 / 26

Define a colour: I()

14 / 26

layout()

functional approach to a layered grammar of graphics

input: plotly object

AdelieChinstrapGentoo020406080100120140
Composition of speciesspecies
15 / 26

Works with %>% operator

penguins %>% plot_ly(x = ~species) %>%
layout(title="Composition of species")
AdelieChinstrapGentoo020406080100120140
Composition of speciesspecies
16 / 26

Modify graphs: add_*

add_histogram

17 / 26

Modify graphs

add_bars (requires pre calculated counts)

18 / 26

Modify graphs (cont.)

14668119AdelieChinstrapGentoo020406080100120140
trace 0trace 1Aaspeciesn
19 / 26

Line graphs

20 / 26

Boxplots

AdelieChinstrapGentoo250030003500400045005000550060006500
speciesbody_mass
21 / 26

Boxplot

3000400050006000Adelie.femaleChinstrap.femaleGentoo.femaleAdelie.maleChinstrap.maleGentoo.male
AdelieChinstrapGentoobody_mass
22 / 26

Combining multiple views

  • Static or dynamic

  • Scatterplot matrices

  • Higer dimensional displayes

  • Arrange multiple plots in a single plane

23 / 26

Combining multiple views

subplot: merge multiple plotly objects.

Overall250030003500400045005000550060006500AdelieChinstrapGentoo
body_mass
24 / 26

Combining multiple views (cont.)

  • splom
14161820221802002203040506030004000500060001416182022180200220
culmen_lengthculmen_depthflipper_lengthculmen_depthflipper_lengthbody_mass
25 / 26

Flexdashboard

Click here

Clickhere

26 / 26

Data

# A tibble: 6 x 7
species island culmen_length culmen_depth flipper_length body_mass sex
<fct> <fct> <dbl> <dbl> <int> <int> <fct>
1 Adelie Torgersen 39.1 18.7 181 3750 male
2 Adelie Torgersen 39.5 17.4 186 3800 female
3 Adelie Torgersen 40.3 18 195 3250 female
4 Adelie Torgersen 36.7 19.3 193 3450 female
5 Adelie Torgersen 39.3 20.6 190 3650 male
6 Adelie Torgersen 38.9 17.8 181 3625 female
species island culmen_length culmen_depth flipper_length
Adelie :146 Biscoe :163 Min. :32.10 Min. :13.10 Min. :172
Chinstrap: 68 Dream :123 1st Qu.:39.50 1st Qu.:15.60 1st Qu.:190
Gentoo :119 Torgersen: 47 Median :44.50 Median :17.30 Median :197
Mean :43.99 Mean :17.16 Mean :201
3rd Qu.:48.60 3rd Qu.:18.70 3rd Qu.:213
Max. :59.60 Max. :21.50 Max. :231
body_mass sex
Min. :2700 female:165
1st Qu.:3550 male :168
Median :4050
Mean :4207
3rd Qu.:4775
Max. :6300
2 / 26
Paused

Help

Keyboard shortcuts

, , Pg Up, k Go to previous slide
, , Pg Dn, Space, j Go to next slide
Home Go to first slide
End Go to last slide
Number + Return Go to specific slide
b / m / f Toggle blackout / mirrored / fullscreen mode
c Clone slideshow
p Toggle presenter mode
t Restart the presentation timer
?, h Toggle this help
Esc Back to slideshow