matplotlib-venn
matplotlib-venn copied to clipboard
Feature request: option to render elements of sets in corresponding Venn diagram regions
It would be excellent if venn2
had an option to render Venn diagram regions with elements of the sets instead of the element count.
matplotlib_venn.venn2([set([1, 2, 3, 4, 5, 6, 7]), set([4, 5, 7, 10, 11])])
which produces this
Could have an option like this:
matplotlib_venn.venn2([set([1, 2, 3, 4, 5, 6, 7]), set([4, 5, 7, 10, 11])], render_elements=True)
which would instead produce this:
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.