LoslegenKostenlos loslegen

Color and opacity

Increasing the transparency (i.e. decreasing the opacity) of a trace can help improve its readability. For example, if there are bars of similar heights in bar charts or histograms, increasing the transparency enables one to see the horizontal grid lines behind the bars, making judgement of relative heights easier. Of course, the hover info can clarify this, but why not make it as easy as possible for your reader?

In this exercise, you will adapt plotly code to change the color of a histogram and increase its transparency.

plotly has already been loaded for you.

Diese Übung ist Teil des Kurses

Interactive Data Visualization with plotly in R

Kurs anzeigen

Anleitung zur Übung

  • Adapt the code so that the bars of the histogram are "navy" and are 50% transparent.

Interaktive Übung

Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.

# Create a histogram of Critic_Score with navy bars that are 50% transparent
vgsales2016 %>%
  plot_ly(x = ~Critic_Score) %>%
  add_histogram(color = ___, opacity = ___)
Code bearbeiten und ausführen