IniziaInizia gratis

Playing with styles

Help Sergeant Laura try out a few different style options. Changing the plotting style is a fast way to change the entire look of your plot without having to update individual colors or line styles. Some popular styles include:

  • 'fivethirtyeight' - Based on the color scheme of the popular website
  • 'grayscale' - Great for when you don't have a color printer!
  • 'seaborn-v0_8' - Based on another Python visualization library
  • 'classic' - The default color scheme for Matplotlib

Questo esercizio fa parte del corso

Introduction to Data Science in Python

Visualizza il corso

Esercizio pratico interattivo

Prova a risolvere questo esercizio completando il codice di esempio.

# Change the style to fivethirtyeight
plt.____.____(____)

# Plot lines
plt.plot(data["Year"], data["Phoenix Police Dept"], label="Phoenix")
plt.plot(data["Year"], data["Los Angeles Police Dept"], label="Los Angeles")
plt.plot(data["Year"], data["Philadelphia Police Dept"], label="Philadelphia")

# Add a legend
plt.legend()

# Display the plot
plt.show()
Modifica ed esegui il codice