Personnaliser la mise en page

Visualisation de données interactive avec plotly en R

Adam Loy

Statistician, Carleton College

layout()

  • axes : type, étiquettes, graduations, transformations, etc.
  • légende : position
  • toile : quadrillage, couleur d'arrière-plan
  • taille : hauteur, largeur, marges
Visualisation de données interactive avec plotly en R

Étiquettes des axes

winequality %>%
  plot_ly(x = ~free_so2, y = ~total_so2) %>%
  add_markers(marker = list(opacity = 0.2)) 
Visualisation de données interactive avec plotly en R

Étiquettes des axes

winequality %>%
  plot_ly(x = ~free_so2, y = ~total_so2) %>%
  add_markers(marker = list(opacity = 0.2)) %>%
  layout(xaxis = list(title = "Free SO2 (ppm)"),
         yaxis = list(title = "Total SO2 (ppm)"))
Visualisation de données interactive avec plotly en R

Titres

winequality %>%
  plot_ly(x = ~free_so2, y = ~total_so2) %>%
  add_markers(marker = list(opacity = 0.2)) %>%
  layout(xaxis = list(title = "Free SO2 (ppm)"),
         yaxis = list(title = "Total SO2 (ppm)"),
         title = "Does free SO2 predict total SO2 in wine?")
Visualisation de données interactive avec plotly en R

Transformer les axes

winequality %>%
  plot_ly(x = ~free_so2, y = ~total_so2) %>%
  add_markers(marker = list(opacity = 0.2)) %>%
  layout(xaxis = list(title = "Free SO2 (ppm, log scale)", type = "log"),
         yaxis = list(title = "Total SO2 (ppm, log scale)", type = "log"),
         title = "Does free SO2 predict total SO2 in wine?")
Visualisation de données interactive avec plotly en R

Personnaliser le quadrillage

Visualisation de données interactive avec plotly en R

Personnaliser le quadrillage

winequality %>%
  plot_ly(x = ~free_so2, y = ~total_so2) %>%
  add_markers(marker = list(opacity = 0.5)) %>%
  layout(xaxis = list(title = "Free SO2 (ppm)", zeroline = FALSE),
         yaxis = list(title = "Total SO2 (ppm)", zeroline = FALSE, 
                      showgrid = FALSE))
Visualisation de données interactive avec plotly en R

Personnaliser la toile

24_bgcolor.png

winequality %>%
  plot_ly(x = ~free_so2, y = ~total_so2) %>%
  add_markers(marker = list(opacity = 0.5)) %>%
  layout(xaxis = list(title = "Free SO2 (ppm)"),
         yaxis = list(title = "Total SO2 (ppm)"),
         plot_bgcolor = toRGB("gray90"),

paper_bgcolor = toRGB("skyblue"))
Visualisation de données interactive avec plotly en R

Passons à la pratique !

Visualisation de données interactive avec plotly en R

Preparing Video For Download...