Skip to main content
Practice

Styling and Themes


Matplotlib includes several built-in styles that allow you to quickly change the appearance of your plots.
You can also fine-tune individual elements to match your preferred look, branding, or presentation theme.


Using Built-in Styles

Use plt.style.use("style_name") to apply a theme globally.

Applying a Built-in Style
import matplotlib.pyplot as plt

plt.style.use("ggplot") # Apply the ggplot theme

x = [1, 2, 3, 4]
y = [10, 20, 15, 25]

plt.plot(x, y)
plt.title("Styled Plot with ggplot")
plt.show()

Popular style names include:

  • "ggplot"
  • "seaborn"
  • "bmh"
  • "dark_background"
  • "fivethirtyeight"

Listing Available Styles

To see what’s available, run:

List Available Styles
print(plt.style.available)

Customizing Individual Elements

You can override specific elements, even when using a theme:

Customize Colors and Line Width
plt.plot(x, y, color="purple", linewidth=3)

This is useful when you want to maintain a consistent style while adjusting key visuals.


What’s Next?

You’ve now explored styling, subplots, labels, and saving — next up is the final quiz to review everything you’ve learned about Matplotlib.

Want to learn more?

Join CodeFriends Plus membership or enroll in a course to start your journey.