Open jimmyocto opened 5 years ago
You can implement something similar using code shown here: https://stackoverflow.com/questions/42855256/python-venn-diagram-how-to-show-the-diagram-contents
Laying out text strings appropriately within given geometric regions is not a trivial task to solve, at least if the aim is to solve it in a manner which would be "generally useful", rather than limited to a couple of toy examples (which can be handled with some custom-crafted code like the one above anyway).
Consequently, I'm not sure I, personally, would be looking at this at the moment. I'm not against someone else trying to solve it, though. In this case I don't think the interface should be defined by a render_elements=True
function parameter. What would actually be needed is a method of the form
def spread_texts(path_patch, texts):
...
You could then apply it as a kind of post-processing to replace the counts with "spread texts" or whatever else you'd need (the complete post-processing method could be added to the matplotlib_venn.utils
package).
I know this issue is old, but you could use my matplotlib-venn-wordcloud to spread the text around in a form filling manner (that's why I wrote that little module to begin with). If that is too quirky, you could align the elements along the midline of each circle segment. The latter approach would only work for venn2
though (IIRC).
Code here.
... so I tried to play a bit with the idea and check out whether simply spreading the set elements randomly along the patches of the diagram works well.
I don't think it does - the wordcloud layout is way neater for sure (although it comes at a cost of a more contrived, pixel-based rendering algorithm).
In case anyone would like to play with this idea more (perhaps it could be adapted to some practical use-case), here is the sample code.
It would be excellent if
venn2
had an option to render Venn diagram regions with elements of the sets instead of the element count.which produces this
Could have an option like this:
which would instead produce this: