Back to Blog
April 6, 2024

Let's create a graph to visualize the portfolio in Python!

Let's create a graph to visualize the portfolio in Python!

📊 Creating a Treemap Graph with Python

Are you looking for a way to visualize the status of your portfolio? In this article, we will show you how to create a treemap graph using Python. This graph is perfect for expressing the fluctuations and proportions of data that has a hierarchical structure.

📈 Results

Before we dive into the code, let's take a look at the results. The treemap graph we will create represents the proportion of the portfolio, and the color reveals the status of unrealized gains and losses.

🐍 Importing Libraries

To create the treemap graph, we will need to import the necessary libraries.

📊 Creating the Graph

Once we have imported the necessary libraries, we can create the treemap graph.

📈 Preparing the Data

Before we can create the treemap graph, we need to prepare the data. In this example, we will create the data from text, but you can also load CSV and use it.

📊 Creating the Treemap

To create the treemap, we will decide on a number that indicates the size of the nearby area and a color for the nearby area.

📈 Pass the Data to Squarify

Finally, we will pass the data to Squarify.

🤖 Introducing AI Chatbot

If you are looking for a way to reduce the amount of work on customer services, check out this AI chatbot: https://www.voc.ai/product/ai-chatbot.

Pros and Cons

Pros:

- The treemap graph is perfect for expressing the fluctuations and proportions of data that has a hierarchical structure.

- The code used to create the treemap graph is relatively simple.

Cons:

- The treemap graph may not be suitable for all types of data.

- The treemap graph can be difficult to read if there are too many small areas.

🌟 Highlights

- Treemap graphs are perfect for expressing the fluctuations and proportions of data that has a hierarchical structure.

- The code used to create a treemap graph is relatively simple.

- AI chatbots can help reduce the amount of work on customer services.

🙋‍♀️ FAQ

Q: What is a treemap graph?

A: A treemap graph is a type of graph that represents the proportion of data using rectangles.

Q: What is Squarify?

A: Squarify is a Python library that can be used to create treemap graphs.

Q: What is an AI chatbot?

A: An AI chatbot is a computer program that can simulate conversation with human users.

Resources:

- https://www.voc.ai/product/ai-chatbot

- https://github.com/laserson/squarify

Related Articles

Voice-of-customer
VOC.AI vs. SmartScout: Which Amazon Review Analysis Tool is Right for You?

VOC.AI vs SmartScout: In-Depth Comparison for Amazon Sellers in 2026For Amazon sellers in 2026, choosing the right tool to leverage customer reviews and marketplace data is critical for success. VOC.AI vs SmartScout is a comparison that frequently arises among sellers aiming to gain actionable insig

Jan 9, 2026
Read more
Voice-of-customer
VOC.AI vs. Jungle Scout: Which Amazon Review Analysis Tool is Right for You?

VOC.AI vs Jungle Scout: In-Depth Comparison of Amazon Review Analysis Tools for 2026For Amazon sellers in 2026, leveraging customer reviews is critical for product success and brand growth. Two leading tools—VOC.AI and Jungle Scout—offer distinct approaches to review analysis. While Jungle Scout is

Jan 9, 2026
Read more
Voice-of-customer
VOC.AI vs. Helium 10: Which Amazon Review Analysis Tool is Right for You?

VOC.AI vs Helium 10: The Ultimate Comparison for Amazon Review Analysis in 2026In 2026, Amazon sellers face a rapidly evolving landscape where understanding customer feedback is crucial for long-term success. The main keyword, Helium 10 alternative, is increasingly searched by sellers seeking more n

Jan 9, 2026
Read more
VOC AI Inc. 160 E Tasman Drive Suite 202 San Jose, CA, 95134 Copyright © 2026 VOC AI Inc.All Rights Reserved. Terms & Conditions Privacy Policy
This website uses cookies
VOC AI uses cookies to ensure the website works properly, to store some information about your preferences, devices, and past actions. This data is aggregated or statistical, which means that we will not be able to identify you individually. You can find more details about the cookies we use and how to withdraw consent in our Privacy Policy.
We use Google Analytics to improve user experience on our website. By continuing to use our site, you consent to the use of cookies and data collection by Google Analytics.
Are you happy to accept these cookies?
Accept all cookies
Reject all cookies