-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMatplotlib(Day23)1.py
More file actions
24 lines (18 loc) · 866 Bytes
/
Matplotlib(Day23)1.py
File metadata and controls
24 lines (18 loc) · 866 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
"""Create a bar chart to represent monthly expenses
in different spending categories and give your conclusion.
Monthly expenses in dollars (replace with your own data) """
# Importing the matplotlib.pyplot library for plotting
import matplotlib.pyplot as plt
# Data: categories and their corresponding expenses
categories = ['Rent', 'Groceries', 'Utilities', 'Entertainment', 'Transportation']
expenses = [1200, 400, 200, 150, 250]
# Setting the figure size for the plot
plt.figure(figsize=(10, 6))
# Creating the bar chart
plt.bar(categories, expenses, color='skyblue')
# Adding labels and title to the chart
plt.xlabel('Categories') # Label for the x-axis
plt.ylabel('Expenses (in dollars)') # Label for the y-axis
plt.title('Monthly Expenses by Category') # Title of the bar chart
# Displaying the bar chart
plt.show()