Plot curves in fivethirtyeight stylesheet in Matplotlib

The FiveThirtyEight stylesheet in Matplotlib provides a clean, professional look inspired by the popular data journalism website. This style features muted colors, subtle gridlines, and typography that makes charts publication-ready.

Setting Up the FiveThirtyEight Style

First, let's configure Matplotlib to use the FiveThirtyEight stylesheet ?

import matplotlib.pyplot as plt
import numpy as np

# Configure figure settings
plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True

# Apply the FiveThirtyEight style
plt.style.use('fivethirtyeight')

print("FiveThirtyEight style applied successfully!")
FiveThirtyEight style applied successfully!

Creating Multiple Curves

Now let's create three curves with different trends to showcase the stylesheet ?

import matplotlib.pyplot as plt
import numpy as np

# Configure figure settings
plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True

# Apply the FiveThirtyEight style
plt.style.use('fivethirtyeight')

# Create x data points
x = np.linspace(0, 10, 50)

# Create figure and subplot
fig, ax = plt.subplots()

# Plot three curves with different patterns
ax.plot(x, np.sin(x) + x + np.random.randn(50), label='Trend A')
ax.plot(x, np.sin(x) + 0.5 * x + np.random.randn(50), label='Trend B')
ax.plot(x, np.sin(x) + 2 * x + np.random.randn(50), label='Trend C')

# Set title and legend
ax.set_title("'fivethirtyeight' style sheet")
ax.legend()

plt.show()

Key Features of FiveThirtyEight Style

The FiveThirtyEight stylesheet includes several distinctive visual elements ?

  • Muted color palette: Subtle, professional colors that work well together
  • Grid styling: Light gray gridlines that don't overpower the data
  • Typography: Clean, readable fonts optimized for data visualization
  • Background: Light gray background that creates visual depth

Comparison with Default Style

Feature Default Style FiveThirtyEight Style
Background White Light gray
Colors Bright, saturated Muted, professional
Grid Black lines Subtle gray lines
Typography Basic Publication-ready

Conclusion

The FiveThirtyEight stylesheet transforms your plots into professional, publication-ready visualizations. Use plt.style.use('fivethirtyeight') to apply this clean, modern aesthetic to any Matplotlib chart.

Updated on: 2026-03-25T22:33:53+05:30

600 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements