Make a treemap chart with Plotly Express
New here? Learn about Bountify and follow @bountify to get notified of new bounties! x

Here is a dataset that I'd like to have visualized in a treemap chart like this. I'd like to have the core focus be on the total tons, with the specific line item, the tons, and the $ of total all visible in the tooltip. Please share the final product as a Plotly standalone URL I can embed somewhere.

Crowdsource coding tasks.

1 Solution


Solution

Hi @msund,

Source code: https://paste.ofcode.org/3hrqSUfqF6ZVXe78YWH24J

Live running example on Chart Studio: https://chart-studio.plotly.com/~vladimir521/1

📎 button in the lower right corner allows you to get a shareable link, embeddable iframe (for embedding chart in your website) invite others etc.

Thank you, Vladimir.

Love it. One more tweak. Could you change the hover text label from "value" to Tons of CO2? Then, yep.
msund 1 month ago
I am pleased to hear that you are satisfied with the solution, but renaming "value" label in the tooltip in Plotly Express Treemap is not possible. It hasn't been implemented yet. The best that I can do would be adding an additional label "Tons of CO2", but the "value" label has to be there.
VladimirMikulic 1 month ago
Updated source code with "Tons of CO2" label can be found here. Chart Studio example has been updated as well. I wish I could do more.
VladimirMikulic 1 month ago
Got it. Is there any chance to remove or hide the "value" trace so it's not duplicate info? Thanks for doing all of this.
msund 1 month ago
Hi @msund. The "value" label can't be hidden completely but to avoid duplicate data, it's value can be set to be an empty string. This should avoid confusion.
VladimirMikulic 1 month ago
Could that'd be great if you could do that so it doesn't show in the hover. Thanks so much
msund 1 month ago
@msund I have some good news. Plotly Express Treemap doesn't allow us to remove/override default values (parent, value), but by using another module I was able to completely clear hover box and customize it to my own likings. Please review it on Chart Studio and let me know if there is anything else I should adjust.
VladimirMikulic 1 month ago
Thanks so much.
msund 1 month ago
You're welcome, thank you on your patience.
VladimirMikulic 1 month ago