Get Started

Adding a title to a FacetGrid object

In the previous exercise, we used relplot() with the miles per gallon dataset to create a scatter plot showing the relationship between a car's weight and its horsepower. This created a FacetGrid object. Now that we know what type of object it is, let's add a title to this plot.

We've already imported Seaborn as sns and matplotlib.pyplot as plt.

This is a part of the course

“Introduction to Data Visualization with Seaborn”

View Course

Exercise instructions

  • Add the following title to this plot: "Car Weight vs. Horsepower".

Hands-on interactive exercise

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

# Create scatter plot
g = sns.relplot(x="weight", 
                y="horsepower", 
                data=mpg,
                kind="scatter")

# Add a title "Car Weight vs. Horsepower"


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

This exercise is part of the course

Introduction to Data Visualization with Seaborn

BeginnerSkill Level
4.8+
99 reviews

Learn how to create informative and attractive visualizations in Python using the Seaborn library.

In this final chapter, you will learn how to add informative plot titles and axis labels, which are one of the most important parts of any data visualization! You will also learn how to customize the style of your visualizations in order to more quickly orient your audience to the key takeaways. Then, you will put everything you have learned together for the final exercises of the course!

Exercise 1: Changing plot style and colorExercise 2: Changing style and paletteExercise 3: Changing the scaleExercise 4: Using a custom paletteExercise 5: Adding titles and labels: Part 1Exercise 6: FacetGrids vs. AxesSubplotsExercise 7: Adding a title to a FacetGrid object
Exercise 8: Adding titles and labels: Part 2Exercise 9: Adding a title and axis labelsExercise 10: Rotating x-tick labelsExercise 11: Putting it all togetherExercise 12: Box plot with subgroupsExercise 13: Bar plot with subgroups and subplotsExercise 14: Well done! What's next?

What is DataCamp?

Learn the data skills you need online at your own pace—from non-coding essentials to data science and machine learning.

Start Learning for Free