# Plotly Treemap not working? - Python

**URL:** <https://community.plotly.com/t/plotly-treemap-not-working-python/30443>\
**Category:** 📊 Plotly Python\
**Created:** [October 24, 2019, 4:26pm UTC](https://community.plotly.com/t/plotly-treemap-not-working-python/30443 "2019-10-24T16:26:21Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![ScroobiusTrip](https://avatars.discourse-cdn.com/v4/letter/s/3be4f8/32.png) [@ScroobiusTrip](https://community.plotly.com/u/ScroobiusTrip)\
**Post date:** [October 24, 2019, 4:26pm UTC](https://community.plotly.com/t/plotly-treemap-not-working-python/30443/1 "2019-10-24T16:26:21Z")

</div>

Hi,

So I’ve been attempting to generate a Treemap using the Plotly docs described here:

> **[Treemap Charts](https://plot.ly/python/treemaps/)**
>
> How to make Treemap Charts with Plotly

However, when I try to generate a basic plot I get the error:

```auto
import plotly.graph_objects as go

df = pd.read_csv('keyword-data.csv')

fig = go.Figure(go.Treemap(
    labels = df['Keyword'],
    parents = df['Topic']
))

fig.show()

```

AttributeError: module ‘plotly.graph\_objects’ has no attribute ‘Treemap’

Has the Treemap plot been deprecated? Is there anyway to get it working?

---

<div class="post-metadata">

**Author:** ![archmoj](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/archmoj/32/8388_2.png) [@archmoj](https://community.plotly.com/u/archmoj)\
**Post date:** [November 8, 2019, 4:33pm UTC](https://community.plotly.com/t/plotly-treemap-not-working-python/30443/2 "2019-11-08T16:33:21Z")

</div>

It is a new trace type.  
Are you using the latest version?

---

<div class="post-metadata">

**Author:** ![radial](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/radial/32/8952_2.png) [@radial](https://community.plotly.com/u/radial)\
**Post date:** [April 2, 2020, 9:34am UTC](https://community.plotly.com/t/plotly-treemap-not-working-python/30443/3 "2020-04-02T09:34:52Z")

</div>

你好 你的这个问题解决了吗?

```python
import plotly.express as px
import pandas as pd
vendors = ["A", "B", "C", "D", None, "E", "F", "G", "H", None]
sectors = ["Tech", "Tech", "Finance", "Finance", "Other",
        "Tech", "Tech", "Finance", "Finance", "Other"]
regions = ["North", "North", "North", "North", "North",
        "South", "South", "South", "South", "South"]
sales = [1, 3, 2, 4, 1, 2, 2, 1, 4, 1]
df = pd.DataFrame(
    dict(vendors=vendors, sectors=sectors, regions=regions, sales=sales)
)
df["all"] = "all" # in order to have a single root node

print(df)
fig = px.treemap(df, path=['all', 'regions',
                        'sectors', 'vendors'], values='sales')
fig.show()

```

我在运行示例时也出现了相同的问题？  
我对应的库版本是  
plotly 4.3.0 pypi\_0 pypi  
plotly-express 0.4.1 pypi\_0 pypi

---

<div class="post-metadata">

**Author:** ![Emmanuelle](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/emmanuelle/32/7853_2.png) [@Emmanuelle](https://community.plotly.com/u/Emmanuelle)\
**Post date:** [April 2, 2020, 12:02pm UTC](https://community.plotly.com/t/plotly-treemap-not-working-python/30443/4 "2020-04-02T12:02:37Z")

</div>

Hi @radial welcome to the forum! The `path` attribute of `px.treemap` was introduced in `plotly 4.5`, please upgrade your version of plotly. Also you can uninstall the `plotly-express` module since it is now part of `plotly`. Could you please write in English another time so that users can understand your posts? Thanks!

---

<div class="post-metadata">

**Author:** ![radial](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/radial/32/8952_2.png) [@radial](https://community.plotly.com/u/radial)\
**Post date:** [April 3, 2020, 5:37am UTC](https://community.plotly.com/t/plotly-treemap-not-working-python/30443/5 "2020-04-03T05:37:23Z")

</div>

Thank you very much，I try it. And my Eiglish is not well. 😅

---

<div class="post-metadata">

**Author:** ![radial](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/radial/32/8952_2.png) [@radial](https://community.plotly.com/u/radial)\
**Post date:** [April 3, 2020, 5:47am UTC](https://community.plotly.com/t/plotly-treemap-not-working-python/30443/6 "2020-04-03T05:47:15Z")

</div>

According to your description, I ran successfully, thank you very much 😀

---

<div class="post-metadata">

**Author:** ![user123](https://avatars.discourse-cdn.com/v4/letter/u/ed655f/32.png) [@user123](https://community.plotly.com/u/user123)\
**Post date:** [April 3, 2020, 6:40pm UTC](https://community.plotly.com/t/plotly-treemap-not-working-python/30443/7 "2020-04-03T18:40:01Z")

</div>

Ok. I did not know that plotly-express was now part of plotly.

---

<div class="post-metadata">

**Author:** ![user123](https://avatars.discourse-cdn.com/v4/letter/u/ed655f/32.png) [@user123](https://community.plotly.com/u/user123)\
**Post date:** [April 3, 2020, 6:42pm UTC](https://community.plotly.com/t/plotly-treemap-not-working-python/30443/8 "2020-04-03T18:42:22Z")

</div>

Is it possible to add an image to a treemap element ? There is a lot of space in those boxes. Ideally, I would like to place a word map in each box. Is there a way to do that ?

---

<div class="post-metadata">

**Author:** ![archmoj](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/archmoj/32/8388_2.png) [@archmoj](https://community.plotly.com/u/archmoj)\
**Post date:** [May 25, 2020, 8:07pm UTC](https://community.plotly.com/t/plotly-treemap-not-working-python/30443/9 "2020-05-25T20:07:20Z")

</div>

@user123 you may consider opening a feature request on [plotly.js repo](https://github.com/plotly/plotly.js/issues) for displaying images in treemap nodes.

---

<div class="post-metadata">

**Author:** ![GuyZa](https://avatars.discourse-cdn.com/v4/letter/g/e0b2c6/32.png) [@GuyZa](https://community.plotly.com/u/GuyZa)\
**Post date:** [January 19, 2021, 7:30pm UTC](https://community.plotly.com/t/plotly-treemap-not-working-python/30443/10 "2021-01-19T19:30:57Z")

</div>

Hey Emmanuelle,  
I am writing a notebook that will be shared across many people in Google Colab and the version there is not updated. I don’t want to force every user to install again and again. What can we use in order to make it work with an older version? (before path was introduced)  
Your assistance will be greatly appreciated,  
Guy
