Black Lives Matter. Please consider donating to Black Girls Code today.

Heatmap from an SVG file

Hi everyone!

I have an svg shape that I’d like to use as a layout for a heatmap. Basically, it’s the board of Monopoly and I’d like to change the color of every cell according to the heatmap.

Any suggestion?

Hi @alessandro_pierro welcome to the forum! So if I understand well, you want to color each rectangle of the monopoly with a different color? You could do this by creating a Figure which would have the monopoly image as a layout image https://plot.ly/python/images/ (you can open the svg with PIL and pass the layout image as a PIL Image object), and create a rectangle shape for every cell (see https://plot.ly/python/shapes/#rectangle-positioned-relative-to-the-plot--to-the-axes). In order to retrieve the geometry of each cell you can use an SVG parser in Python, there seem to be many. This is a bit convoluted, but one the other hand this is not a standard visualization :-).