Aan de slagGa gratis aan de slag

Plotting symbols

Recall that plotly allows you to customize the plotting symbols used through the symbols argument to add_markers(). Both numeric and character specifications of symbols are permitted. For example, 100 denotes an open circle which can also be specified as "circle-open".

To manually specify the scale for, say, three levels you can specify symbols = c("circle", "triangle", "x") to ensure that the groups are represented by circles, triangles, and x's, in that order.

Here's the full list of valid plotting symbols for your reference.

In this exercise, you'll change the plotting symbols for the income categories.

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

Deze oefening maakt deel uit van de cursus

Intermediate Interactive Data Visualization with plotly in R

Cursus bekijken

Oefeninstructies

  • Change the plotting symbols for income categories according to the following scheme:
  • low: "circle-open"; lower-middle: "square-open"; upper-middle: "star-open"; high: "x-thin-open"

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Fill in the specified plotting symbols
happy %>%
  plot_ly(x = ~life.expectancy, y = ~happiness) %>%
  add_markers(symbol = ~income, symbols = c(___, ___, ___, ___))
Code bewerken en uitvoeren