Sometimes there're narrow bricks on treemaps. Plotly decrease the font size of such a labels, so you cannot read them. But another way is making thease labels horizontal. As far as I understood the only way to rotate labels in Plotly is using JavaScript. I'm new at it, please help to understand how to select some particular node with JS? Here's the example code, where I try to rotate the label 'a1' (but fail): data = {'level1': ['A', 'A', 'B', 'B'], 'level2': ['a1', 'a2', 'b1', 'b2']} fig = px.treemap(data, path=['level1', 'level2']) js = """ function rotateLabel(){ const nodes = gd.querySelectorAll('slicetext'); for (const node of nodes){ const label = node.querySelector('[data-unformatted="a1"]'); label.style.transform = 'rotate(90deg)'; } } const gd = document.querySelector('.plotly-graph-div'); gd.on('plotly_afterplot', rotateLabel.bind(gd)); gd.emit('plotly_afterplot'); """ fig.show(post_script=[js]) Continue reading...