Pie Charts and Poor Spending Habits: A Colorful Confession

Day 40 of 100 Days Coding Challenge: Python

I’ve been tracking my personal expenses in Excel for years—part frugality, part paranoia, and part curiosity about where my coffee budget keeps disappearing. While rows and columns get the job done, they aren’t exactly thrilling.

So, I decided to give my budget a little makeover. I created a Python Expense Tracker App. Over the past couple of days, I’ve been fiddling with matplotlib, playing with lines and bars like a spreadsheet Picasso. Today, I thought, ā€œWhy not turn this into a pie chart?ā€ā€”because nothing says responsible adulting like slicing your expenses into pizza-shaped regret. For this mini project, I spared myself the embarrassment of my actual spending and used a clean, innocent example instead. Baby steps.

Today’s Motivation / Challenge


We all love to believe we’re financially savvy… until we see it in a chart and realize we’ve spent more on takeout than utilities. Visualizing data is like turning on a light in a messy room—you suddenly see everything you were ignoring. Pie charts are a beginner-friendly way to practice working with visualizations, and let’s face it: they’re much easier to interpret than bar charts if you’re half-awake with your morning tea.

Purpose of the Code (Object)


This code creates a pie chart that shows how your expenses are split among categories like rent, groceries, and ā€œmiscellaneous,ā€ which is often just code for impulse purchases. It helps turn numbers into visuals so you can actually understand where your money goes—without scrolling through endless rows in a spreadsheet.

AI Prompt: 


Write a Python script that generates a pie chart of personal expenses using matplotlib.

Functions & Features

  • Breaks down expenses into categories.
  • Assigns colors to each slice for easier viewing.
  • Automatically calculates percentages and displays them on the chart.

Requirements / Setup

You’ll need:

pip install matplotlib

Minimal Code Sample

plt.pie(expenses, labels=categories, autopct=’%1.1f%%’)

plt.axis(‘equal’)  # Makes the pie chart look like a circle

This generates the core of your pie chart and ensures it’s not shaped like an egg.

Expense Tracker Pie Chart

Notes / Lessons Learned


The code itself wasn’t hard to wrangle—it’s the file names that got me. I confidently ran my script, only to watch Python stare at me blankly. Turns out I’d named the file incorrectly and had the right environment with the wrong target. It’s like dialing the right number but calling the wrong person. Also, adding more categories is easy, but unless you want all your slices to look the same shade of gray, you’ll need to manage your colors better. Next time, pulling data from a CSV file, like a bank statement, would make the tool far more practical—and possibly more shocking.

Optional Ideas for Expansion

  • Import expense data directly from a CSV file.
  • Add a legend to clarify which color means what (before purple becomes both rent and groceries).
  • Turn it into a simple GUI with category input for non-coders.

Leave a Reply

Your email address will not be published. Required fields are marked *