Aan de slagGa gratis aan de slag

Styling scientific research

Now that you have mastered customizing your plots, it is time to let your creative energy flow!

In this exercise, you are continuing your work with the Antarctic research team to assist them in exploring and understanding the penguin data they have collected.

They have asked you to help them understand how the flipper length differs between species. Time is short, so you think a quick plotly.express visualization would do. However, they also want some specific customizations for the axes' titles.

You have available a penguins DataFrame.

Deze oefening maakt deel uit van de cursus

Introduction to Data Visualization with Plotly in Python

Cursus bekijken

Oefeninstructies

  • Create a plotly bar chart from the penguins DataFrame with the title "Flipper Length (mm) by Species", the x-axis as "spec", the y-axis as "av_flip_length".
  • Use the .update_layout() method to change the xaxis and yaxis text to "Species" and "Average Flipper Length (mm)" respectively.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Create the plot
fig = px.bar(penguins, x="____", y="____", title="____", color="spec")

# Change the axis titles
fig.update_layout(
    xaxis=dict(title=dict(text="____")),
    yaxis=dict(title=dict(text="____"))
)

# Show the plot
fig.show()
Code bewerken en uitvoeren