Notes on algorithm used
Hi,
I would like to ask if there is a section that describes the algorithm used or in general the methodology so that I do not have to go through the code and figure it out from there.
I am asking this because I am looking for the specific algorithm used when comparing projects, but could not find any notes on this here.
Besides that, very nice project !!!
Hi, a very reasonable request, but I don't have a description at the moment, sorry! ggrepel has a better description, and I loosely based this project on that, without actually looking at the code there though (I don't know R anyway).
A brief description is:
- Iteratively try all alignment options for each text object, to minimize overlaps
- Force all text objects to not overlap axes bounds
- Then, iteratively calculate where to move each text object, based on its overlaps with other text objects, points, and objects, apply the move, ensuring the texts are not going outside axes bound. Repeat until
- no overlaps remain
- or until limit of number of iterations is reached.
- or - a tricky part - until certain "precision" is achieved (i.e. combined length of overlaps is lower than certain fraction of combined lengths/widths of all text objects).
- finally - if there is a sign that the process is not converging, and the overlap has increased over one of the previous 10 steps of the iterations.
You'll have to check the code for the details of the implementation unfortunately, sorry!
Thanks for clarifying. That is all I needed.
If you find the time, it might be nice to update the docs and add a section à la "how it works", just to clarify that it is not some standard algorithm you use.
Thanks, you are right!
Are there any standard algorithms for this, that are actually implemented somewhere and work reasonably well?
Yeah so I think Graphviz has some nice algorithms that could be useful.
But it is not straight forward to get this into MPL.
Something like this, from networkx? https://stackoverflow.com/a/34697108/1304161