Introduction
Matplotlib helps you turn numbers into pictures. It makes data easy to understand by showing it as charts and graphs.
Matplotlib helps you turn numbers into pictures. It makes data easy to understand by showing it as charts and graphs.
import matplotlib.pyplot as plt plt.plot(x, y) plt.show()
plt.plot() to create a simple line chart.plt.show() to display the chart window.import matplotlib.pyplot as plt x = [1, 2, 3] y = [4, 5, 6] plt.plot(x, y) plt.show()
import matplotlib.pyplot as plt x = [1, 2, 3] y = [4, 5, 6] plt.bar(x, y) plt.show()
import matplotlib.pyplot as plt labels = ['A', 'B', 'C'] sizes = [30, 50, 20] plt.pie(sizes, labels=labels) plt.show()
This program draws a line chart showing sales for each month. It adds labels and a grid for clarity.
import matplotlib.pyplot as plt # Sample data: sales over 4 months months = ['Jan', 'Feb', 'Mar', 'Apr'] sales = [250, 300, 400, 350] plt.plot(months, sales, marker='o') plt.title('Monthly Sales') plt.xlabel('Month') plt.ylabel('Sales') plt.grid(True) plt.show()
Matplotlib works well with many data types and is very flexible.
You can customize almost every part of your chart.
It is widely used, so many tutorials and help are available online.
Matplotlib turns data into easy-to-understand pictures.
It helps find patterns and share results clearly.
It is simple to start and powerful to grow with.
import matplotlib.pyplot as plt plt.plot([1, 2, 3], [4, 5, 6]) plt.show()
import matplotlib.pyplot as plt plt.plot([1, 2, 3], [4, 5]) plt.show()
Pass the test and this pattern moves unknown