Je lay-out aanpassen

Interactieve datavisualisatie met plotly in R

Adam Loy

Statistician, Carleton College

layout()

  • assen: type, labels, schaalstrepen, transformaties, enz.
  • legenda: positie
  • canvas: rasterlijnen, achtergrondkleur
  • grootte: hoogte, breedte, marges
Interactieve datavisualisatie met plotly in R

Aslabels

winequality %>%
  plot_ly(x = ~free_so2, y = ~total_so2) %>%
  add_markers(marker = list(opacity = 0.2)) 
Interactieve datavisualisatie met plotly in R

Aslabels

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)"))
Interactieve datavisualisatie met plotly in R

Titels

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 = "Voorspelt vrije SO2 de totale SO2 in wijn?")
Interactieve datavisualisatie met plotly in R

Assen transformeren

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 = "Voorspelt vrije SO2 de totale SO2 in wijn?")
Interactieve datavisualisatie met plotly in R

Het raster aanpassen

Interactieve datavisualisatie met plotly in R

Het raster aanpassen

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))
Interactieve datavisualisatie met plotly in R

Het canvas aanpassen

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"))
Interactieve datavisualisatie met plotly in R

Laten we oefenen!

Interactieve datavisualisatie met plotly in R

Preparing Video For Download...