Menyesuaikan tata letak

Visualisasi Data Interaktif dengan plotly di R

Adam Loy

Statistician, Carleton College

layout()

  • sumbu: tipe, label, tanda skala, transformasi, dll.
  • legenda: posisi
  • kanvas: garis grid, warna latar
  • ukuran: tinggi, lebar, margin
Visualisasi Data Interaktif dengan plotly di R

Label sumbu

winequality %>%
  plot_ly(x = ~free_so2, y = ~total_so2) %>%
  add_markers(marker = list(opacity = 0.2)) 
Visualisasi Data Interaktif dengan plotly di R

Label sumbu

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)"))
Visualisasi Data Interaktif dengan plotly di R

Judul

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 = "Apakah SO2 bebas memprediksi total SO2 pada wine?")
Visualisasi Data Interaktif dengan plotly di R

Transformasi sumbu

winequality %>%
  plot_ly(x = ~free_so2, y = ~total_so2) %>%
  add_markers(marker = list(opacity = 0.2)) %>%
  layout(xaxis = list(title = "Free SO2 (ppm, skala log)", type = "log"),
         yaxis = list(title = "Total SO2 (ppm, skala log)", type = "log"),
         title = "Apakah SO2 bebas memprediksi total SO2 pada wine?")
Visualisasi Data Interaktif dengan plotly di R

Menyesuaikan grid

Visualisasi Data Interaktif dengan plotly di R

Menyesuaikan grid

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))
Visualisasi Data Interaktif dengan plotly di R

Menyesuaikan kanvas

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"))
Visualisasi Data Interaktif dengan plotly di R

Ayo berlatih!

Visualisasi Data Interaktif dengan plotly di R

Preparing Video For Download...