Skip to content
Sonu edited this page Aug 21, 2025 · 1 revision

Welcome to the matplotlib_course wiki!

📊 Matplotlib Course for Beginners – Wiki

  • Welcome to the Wiki of Matplotlib Course for Beginners 🎉

  • This Wiki will guide you step by step to learn Matplotlib, the most popular data visualization library in Python.

🚀 Installation Guide

1.Install Python (3.8 or higher recommended).

2.Create a virtual environment (optional but recommended).

3.Install the required libraries

pip install matplotlib numpy

📝 Basic Concepts

Figure → The overall window where plots are drawn.

Axes → The area where the data is plotted (x-axis, y-axis).

Plot → The actual graph (line, bar, scatter, etc.).

import matplotlib.pyplot as plt plt.plot([1, 2, 3], [4, 5, 6]) plt.title("Basic Plot") plt.show()

📂 Topics

  1. Axis Functions

Set labels, limits, and ticks.

plt.plot([0,5],[0,10]) plt.title("Axis Example") plt.xlabel("X-axis") plt.ylabel("Y-axis") plt.xlim(0,6) plt.ylim(0,12) plt.show()

  1. Bar Plot x = ["A","B","C","D"] y = [3,7,5,4] plt.bar(x,y,color="skyblue") plt.title("Bar Plot") plt.show()

  2. Box Plot import numpy as np data = np.random.randn(100) plt.boxplot(data) plt.title("Box Plot") plt.show()

  3. Fill Between Plot import numpy as np x = np.linspace(0,10,100) y1 = np.sin(x) y2 = np.cos(x) plt.fill_between(x,y1,y2,color="lightgreen",alpha=0.5) plt.title("Fill Between Plot") plt.show()

  4. Histogram Plot data = np.random.randn(1000) plt.hist(data,bins=30,color="orange",edgecolor="black") plt.title("Histogram") plt.show()

  5. Linear (Line) Plot x = [1,2,3,4,5] y = [2,4,6,8,10] plt.plot(x,y,marker="o") plt.title("Line Plot") plt.show()

  6. Pie Chart sizes = [20,30,25,25] labels = ["A","B","C","D"] plt.pie(sizes,labels=labels,autopct="%1.1f%%") plt.title("Pie Chart") plt.show()

  7. Scatter Plot x = np.random.rand(50) y = np.random.rand(50) plt.scatter(x,y,color="red") plt.title("Scatter Plot") plt.show()

  8. Stack Plot days = [1,2,3,4,5] a = [3,2,4,5,6] b = [1,4,2,6,7] c = [2,3,5,7,2] plt.stackplot(days,a,b,c,labels=["A","B","C"]) plt.legend() plt.title("Stack Plot") plt.show()

  9. Stem Plot x = np.linspace(0.1,2*np.pi,10) y = np.cos(x) plt.stem(x,y) plt.title("Stem Plot") plt.show()

  10. Step Plot x = [1,2,3,4,5] y = [2,4,6,8,10] plt.step(x,y,where="mid") plt.title("Step Plot") plt.show()

  11. Subplots fig,ax = plt.subplots(2,2) ax[0,0].plot([1,2,3],[1,2,3]) ax[0,1].bar(["A","B","C"],[3,5,7]) ax[1,0].scatter([1,2,3],[3,2,1]) ax[1,1].hist(np.random.randn(100)) plt.suptitle("Subplots Example") plt.show()

  12. Save Figure x = [1,2,3,4,5] y = [10,8,6,4,2] plt.plot(x,y,marker="o",color="red",label="Line Plot") plt.title("Save Figure Example") plt.xlabel("X-axis") plt.ylabel("Y-axis") plt.legend() plt.savefig("images/savefigure.png") plt.show()

❓ FAQ

Q. Plot show नहीं हो रहा है? 👉 Solution: Make sure you write plt.show() at the end.

Q. Figure save नहीं हो रही? 👉 Solution: Use plt.savefig("filename.png") before plt.show().

Q. ModuleNotFoundError: matplotlib? 👉 Solution: Run pip install matplotlib.

Clone this wiki locally