Matplotlib

 Matplotlib is a powerful Python library for creating visualizations. It offers a wide range of built-in functions to create various types of plots and charts.

1. Line Graphs:

Line graphs are used to visualize trends over time or relationships between variables. They are created using the plt.plot() function.

import matplotlib.pyplot as plt 
x = [3, 1, 3] 
y = [3, 2, 1] plt.plot(x, y) 
plt.title("Line Chart") 
plt.legend(["Line"]) 
plt.show() 

2. Bar Charts

Bar charts represent categories of data with rectangular bars, where the length or height of the bars is proportional to the values they represent. They are created using the plt.bar() function.

import matplotlib.pyplot as plt 
x = [3, 1, 3, 12, 2, 4, 4] 
y = [3, 2, 1, 4, 5, 6, 7] 
plt.bar(x, y)
plt.title("Bar Chart")
plt.legend(["bar"])
plt.show()

3. Histograms

Histograms visualize the distribution of continuous data. They are a type of bar plot where the X-axis represents bin ranges and the Y-axis represents frequency. They are created using the plt.hist() function.

import matplotlib.pyplot as plt 
x = [1, 2, 3, 4, 5, 6, 7, 4] 
plt.hist(x, bins = [1, 2, 3, 4, 5, 6, 7])
plt.title("Histogram")
plt.legend(["bar"])
plt.show()

4. Scatter Plots:

Scatter plots display individual data points as dots and are useful for showing relationships between two variables. They are created using the plt.scatter() function.

import matplotlib.pyplot as plt 
x = [3, 1, 3, 12, 2, 4, 4]
y = [3, 2, 1, 4, 5, 6, 7]
plt.scatter(x, y)
plt.legend("A")
plt.title("Scatter chart")
plt.show()

Pie Charts:

Pie charts represent proportions of different categories, with the area of each slice (or wedge) representing the percentage of that part of the data. They are created using the plt.pie() function.

import matplotlib.pyplot as plt  
x = [1, 2, 3, 4] 
e  =(0.1, 0, 0, 0)
plt.pie(x, explode = e)
plt.title("Pie chart")
plt.show()