Get startedGet started for free

Using matplotlib axes

Seaborn uses matplotlib as the underlying library for creating plots. Most of the time, you can use the Seaborn API to modify your visualizations but sometimes it is helpful to use matplotlib's functions to customize your plots. The most important object in this case is matplotlib's axes.

Once you have an axes object, you can perform a lot of customization of your plot.

In these examples, the US HUD data is loaded in the dataframe df and all libraries are imported.

This exercise is part of the course

Intermediate Data Visualization with Seaborn

View Course

Exercise instructions

  • Use plt.subplots() to create a axes and figure objects.
  • Plot a histplot of column fmr_3 on the axes.
  • Set a more useful label on the x axis of "3 Bedroom Fair Market Rent".

Hands-on interactive exercise

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

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

# Plot the distribution of data
sns.histplot(df['fmr_3'], ax=ax)

# Create a more descriptive x axis label
ax.set(____="3 Bedroom Fair Market Rent")

# Show the plot
plt.show()
Edit and Run Code