Changing the width of the borders in a Plotly treemap

Viewed 303

Is it possible to change the width of the borders in a Plotly treemap? I am referring to the white borders separating each individual box in the treemap below.

import plotly.express as px
df = px.data.tips()
fig = px.treemap(df, path=[px.Constant("all"), 'day', 'time', 'sex'], values='total_bill')
fig.update_traces(root_color="lightgrey")
fig.update_layout(margin = dict(t=50, l=25, r=25, b=25))
fig.show()

enter image description here

Edit: A workaround is to change stroke-width in the resulting SVG file. However, it would be nice if this can be done automatically.

1 Answers

Those are actually not borders, but the lines of the markers for each trace, so you can use:

fig.update_traces(marker_line_width = 4)

And get:

enter image description here

Complete code:

import plotly.express as px
df = px.data.tips()
fig = px.treemap(df, path=[px.Constant("all"), 'day', 'time', 'sex'], values='total_bill')
fig.update_traces(root_color="lightgrey")
fig.update_layout(margin = dict(t=50, l=25, r=25, b=25))
fig.update_traces(marker_line_width = 4)
fig.show()
Related