Get startedGet started for free

Species on different islands

The Antarctic research scientists are back with another brief. They want to be able to visualize how their data collection counts differ between species and islands.

Specifically, they want to easily compare islands based on the count of different species of penguins they recorded there.

You have the perfect plot - you will layer several bar charts together for easy comparison!

You have been provided a penguins_grouped DataFrame that has the count of samples for each species at each island as well as an islands list of the different islands where research was undertaken.

This exercise is part of the course

Introduction to Data Visualization with Plotly in Python

View Course

Exercise instructions

  • View the printed out penguins_grouped DataFrame to see its structure.
  • Create an empty figure object.
  • Loop through the species, adding a bar chart trace to the base figure.
  • Set the appropriate y subset and name for the bar chart trace being added.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Create the base figure
fig = go.____

# Loop through the species
for species in ['Adelie', 'Chinstrap', 'Gentoo']:
  # Add a bar chart trace
  fig.____(go.____(x=islands,
    # Set the appropriate y subset and name
    y=penguins_grouped[penguins_grouped.Species == ____]['Count'],
    name=____))
# Show the figure
fig.show()
Edit and Run Code