Customizing charts makes your visualizations more attractive, clear, and professional.
In Data Analytics, well-formatted charts improve readability and presentation quality.
First, import Matplotlib:
import matplotlib.pyplot as plt
Sample Data
months = ["Jan", "Feb", "Mar", "Apr", "May"]
sales = [10000, 15000, 20000, 18000, 25000]
1. Changing Line Style and Color
plt.plot(months, sales, color="blue", linestyle="--", marker="o")
plt.title("Monthly Sales")
plt.show()
Common options:
- color = “red”, “green”, “blue”
- linestyle = “-“, “–“, “-.”, “:”
- marker = “o”, “s”, “^”, “*”
2. Adding Title and Axis Labels
plt.plot(months, sales)
plt.title("Monthly Sales Report")
plt.xlabel("Months")
plt.ylabel("Sales Amount")
plt.show()
3. Adjusting Figure Size
plt.figure(figsize=(8, 5))
plt.plot(months, sales)
plt.title("Monthly Sales")
plt.show()
4. Adding Grid
plt.plot(months, sales)
plt.grid(True)
plt.show()
5. Adding Legend
plt.plot(months, sales, label="Sales")
plt.legend()
plt.show()
6. Rotating X-Axis Labels
plt.plot(months, sales)
plt.xticks(rotation=45)
plt.show()
7. Changing Font Size
plt.title("Monthly Sales", fontsize=16)
plt.xlabel("Months", fontsize=12)
plt.ylabel("Sales", fontsize=12)
8. Adding Annotations
plt.plot(months, sales)
plt.annotate("Highest Sales", xy=("May", 25000), xytext=("Mar", 26000),
arrowprops=dict(facecolor="black"))
plt.show()
9. Adjusting Layout
plt.tight_layout()
This prevents overlapping elements.
Why Customization is Important
Customization helps you:
Improve readability
Highlight important insights
Make professional dashboards
Present data clearly in reports
Improve audience understanding
Key Takeaway
Customizing charts transforms simple graphs into professional visualizations.
Proper formatting, labels, legends, and layout adjustments are essential skills for effective data presentation in analytics projects.