MaartenGr / MaartenGr/BERTopic

Cannot Implement Multi-color Intertopic Distance Map Visualization

Open
#1,496 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
7.8k
Forks
920
Avg merge
22h 24m
Merged PRs (30d)
5

Description

Hello,

I'm trying to customize the intertopic distance map in BERTopic to show different color bubbles for each topic. I've attempted to modify the _topic.py file to include Seaborn's color palette but haven't achieved the desired effect. I am wondering how best to proceed.

My Approach
Here is the relevant section of code I modified in the _topic.py file to support multi-color visualization:

```
# I added this code to generate different colours
color_palette = sns.color_palette("hsv", len(topics)).as_hex()

# ... continued with other parts of the code
df = pd.DataFrame({"x": embeddings[:, 0], "y": embeddings[:, 1],
"Topic": topic_list, "Words": words, "Size": frequencies, "Color": color_palette})
```

I did not see any change in the colors of the bubbles after running this modified code.

What I Expected:
I expected to see each bubble in the intertopic distance map with a unique color, as defined by the Seaborn's color palette.

What Happened:
However, the colors in the intertopic distance map remained unchanged.

Questions:
Is the _topic.py the correct place to modify for customizing colors in the intertopic distance map?
Are there specific steps or methods within BERTopic that I need to utilize to change the colors effectively?
Could you guide me on how to modify the code so that it would achieve the desired multi-color visualization?
Thank you for your time and consideration. I look forward to your guidance to resolve this issue.

Best regards,
Paris Kang

![newplot (22)](https://github.com/MaartenGr/BERTopic/assets/13728918/1ce2c168-1fe4-44cb-8874-0cd794e926f3)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in _topic.py and trace how the intertopic distance map assigns bubble colors after the DataFrame is created. Compare the requested Seaborn palette with the visualization path; done means each topic bubble displays a distinct color without changing the map's existing behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data-visualization
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.