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.
Deze oefening maakt deel uit van de cursus
Intermediate Data Visualization with Seaborn
Oefeninstructies
- Use
plt.subplots()to create a axes and figure objects. - Plot a
histplotof columnfmr_3on the axes. - Set a more useful label on the x axis of "3 Bedroom Fair Market Rent".
Praktische interactieve oefening
Probeer deze oefening eens door deze voorbeeldcode in te vullen.
# 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()