LoslegenKostenlos loslegen

Additional plot customizations

The matplotlib API supports many common customizations such as labeling axes, adding titles, and setting limits. Let's complete another customization exercise.

Diese Übung ist Teil des Kurses

Intermediate Data Visualization with Seaborn

Kurs anzeigen

Anleitung zur Übung

  • Create a histplot of the fmr_1 column.
  • Modify the x axis label to say "1 Bedroom Fair Market Rent".
  • Change the x axis limits to be between 100 and 1500.
  • Add a descriptive title of "US Rent" to the plot.

Interaktive Übung

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

# Create a figure and axes
fig, ____ = plt.subplots()

# Plot the distribution of 1 bedroom rents
sns.____(df['fmr_1'], ax=____)

# Modify the properties of the plot
ax.set(xlabel="1 Bedroom Fair Market Rent",
       xlim=(____,____),
       ____="US Rent")

# Display the plot
plt.show()
Code bearbeiten und ausführen