#4 Add title and axis label




In this post we show how to add title and axis label to your python chart using matplotlib. Here is an example applied on a barplot, but the same method works for other chart types.








# libraries
import numpy as np
import matplotlib.pyplot as plt

# Fake dataset
height = [3, 12, 5, 18, 45]
bars = ('A', 'B', 'C', 'D', 'E')
y_pos = np.arange(len(bars))

# Create bars and choose color
plt.bar(y_pos, height, color = (0.5,0.1,0.5,0.6))

# Add title and axis names
plt.title('My title')

# Limits for the Y axis

# Create names
plt.xticks(y_pos, bars)

# Show graphic

  • Sponsors

  • Leave a Reply

    Your email address will not be published.