BaşlayınÜcretsiz Başlayın

Polishing your graphics

The below code chunk produces an interactive plot of national happiness against an index for social support, where plotting symbols represent the income classification of the country.

happy %>%
  plot_ly(x = ~social.support, y = ~happiness,
  hoverinfo = "text",
  text = ~paste("Country: ", country)) %>%
  add_markers(symbol = ~income, symbols = c("circle-open", "square-open", "star-open", "x-thin-open"))

Your task is to edit the hover information and axis labels so that your reader can more-easily digest the information.

plotly and the happy data set have been loaded for you.

Bu egzersiz

Intermediate Interactive Data Visualization with plotly in R

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Add hover information for the income group, happiness score, and the social.support index.
  • Use round(<variable>, 2) to round all numeric variables to two decimal places in the hover info.
  • Change the x-axis label to "Social support index" and the y-axis label to "National happiness score".

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Complete the following code to polish the plot
happy %>%
  plot_ly(x = ~social.support, y = ~happiness,
  hoverinfo = "text",
  text = ~paste("Country: ", country,
  "
Income: ", ___, "
Happiness: ", ___, "
Social support: ", ___)) %>% add_markers(symbol = ~income, symbols = c("circle-open", "square-open", "star-open", "x-thin-open")) %>% layout(xaxis = ___, yaxis = ___)
Kodu Düzenle ve Çalıştır