New Pie Chart for My Monthly Report

I added a pie chart to describe my Networth Breakdown to my codebase. The idea here is to have one program that can generate a lot of the images, tables, and charts for my monthly updates. For me, it’s also a fun way for me to practice with a language I am still expanding my skills in.

May 2019 Net worth Breakdown

This isn’t much of a post, nor is it particularly complicated. I feel like I should add a bit more meat to this post, so let me show you the source code for this function, and give you a bit of background on some choices.

The data itself is stored in the object that I use to contain all my networth functions with separate class variables holding the 3 values shown. That work was already done by me earlier on to generate other data that you have seen this month, so all I had to do was to find a graphing module.

I was using plotly, but they want you to log in and they have a pay scale to use it. It’s fine the community version of that is what I use for my other graphs. When I tried to use their pie chart, though, they asked for a login. My primary reason not to use it is simply that it’s another log in. I’d rather not have to do that, so instead, I tried matplotlib, and that created this chart. Both seem fine tools to me, and I will continue to use plotly for my line graphs, but why not try a few others.

    def plot_net_worth_pie(self):
        labels = ['Home Value', 'Retirement Accounts Value', 'Non Retirement Accounts Value']
        sizes = [self.home_net/self.net_worth*360, self.retire_net/self.net_worth*360,
                 self.non_retire_net/self.net_worth*360]

        colors = ['yellowgreen', 'lightcoral', 'lightskyblue']

        plt.pie(sizes, labels=labels, colors=colors,
                autopct='%1.1f%%', shadow=True, startangle=120)

        plt.axis('equal')
        plt.show()

As you can see, there is not much to this, so I am very happy with what I have here. Generating the tables for the years to retirement was much harder, and consequently more fun for me to do. I’ll probably have a few more of these posts as I work on it and add new features.

I’d love to hear if you have any thoughts.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.