These are my lecture for University and College level students.
import matplotlib.pyplot as plt
%matplotlib inline
#car model names
models=['Accord Sedan', 'Civic Hybrid', 'Civic Sedan', 'Crosstour', 'CR-V', 'Fit', 'Odyssey', 'Pilot', 'Ridgeline']
#suggested retail prices
prices=[21680, 24200, 18165, 27230, 22795, 15425, 28675, 29520, 29450]
plt.figure(figsize=(10,6))
plt.bar(models,prices, color='skyblue')
plt.xlabel('Car Models')
plt.ylabel('Suggested Retail Price ($)')
plt.title('Suggested Retail Prices of Cars Models')
plt.xticks(rotation=45,ha='right')
plt.tight_layout()
plt.show()
rotation=45: This parameter specifies the angle (in degrees) by which the x-axis tick labels should be rotated. In this case, the labels are rotated by 45 degrees clockwise. This can be useful when the labels are long or overlap with each other, and rotating them improves readability.
ha='right': This parameter stands for horizontal alignment and is set to 'right'. It determines how the rotated tick labels should be aligned horizontally. In this case, 'right' means that the right end of the rotated labels will be aligned. This is often used in conjunction with rotation to prevent the labels from overlapping with the plot area.