Python graph how to windirstat?

I am interested in using python to create diagrams representing the size of values ​​based on the size of the squares (and, if necessary, their color). I'm basically looking for a way to review a bunch of values, such as the old old windirstat program (basically it's a big square representing your hard drive, and then the smaller squares that make up the area inside it representing different programs, the larger the square, the larger the file, color indicates file type). I am pretty familiar with matplotlib, and I don't think it can be done with this. Is there any other python package that would help? Any suggestions for something lower level if it isn't? I guess I could do it manually if I could find a way to draw boxes programmatically (I don't care what the format, but the option to export SVG, as well as PNG would be nice).

Ultimately, it would be nice to have it interactive, like windirstat, where if you hover over a certain square, you get more information about it, and if you clicked on it, maybe you would go in and see the composition of this particular area. I am only familiar with wxpython for the GUI, not sure if it can be used for anything like that. For now, I would be happy just by pulling them out, though.

Thanks a lot! Alex

Edit: Thanks guys, your answers really helped.

+6
source share
2 answers

You are looking for Treemapping algorithms. After implementation, you can convert the output (which should be a rectangle) into build commands for anything that layered rectangles can draw.

Edit:

Additional links and information:

If you don't mind reading articles, the browser-based d3 library provides “quadratic” treemaps ( js implementation ). They cite this article by Bruls, Huizing, and van Wijk . (This is also quote 3 on the Wikipedia article)

I would look for the algorithms listed in the related Wikipedia article. For example, they also refer to this article , which describes the algorithm for "mixed treemaps". The document also presents some interesting snippets at the end of the description of transformations to shapes other than rectangles.

Of course, Squarified is the most common variety. The above links should give you enough to work on the solution, or even directly port the d3 implementation. However, the cost of a grokking d3 model (something like a jQuery declarative form) can be a little high. At first glance, however, the implementation looks relatively simple.

+7
source

Squaremap does this. I have not used it (I know this only from RunSnakeRun ), and its documentation is very lacking, but it seems to work.

+1
source

Source: https://habr.com/ru/post/906041/


All Articles