konstantint / matplotlib-venn

Area-weighted venn-diagrams for Python/matplotlib
MIT License
520 stars 68 forks source link

Circles for unweighted diagrams #39

Closed aldantas closed 6 years ago

aldantas commented 6 years ago

Is it possible to implement a function for drawing the circles of unweighted diagrams? I've tried to tweak the venn3_circle function using a (1,1,1,1,1,1,1) tuple for the areas, like the unweighted wrap functions do, but it didn't work.

from matplotlib import pyplot as plt
from matplotlib_venn import venn3_circles, venn3_unweighted
from matplotlib_venn import _common, _venn3
from matplotlib.patches import Circle
subsets=(2, 3, 5, 1, 2, 0, 1)
v = venn3_unweighted(subsets, set_labels = ('A', 'B', 'C'))
areas = (1, 1, 1, 1, 1, 1, 1)
centers, radii = _venn3.solve_venn3_circles(areas)
ax = plt.gca()
_common.prepare_venn_axes(ax, centers, radii)
for (c, r) in zip(centers, radii):
    print(c)
    circle = Circle(c, r, alpha=1.0, edgecolor='black', facecolor='none',
                    linestyle='solid', linewidth=2.0)
    ax.add_patch(circle)
plt.show()

figure_1

konstantint commented 6 years ago

What's the problem with

venn3_circles((1,1,1,1,1,1,1))

? It provides exactly the same circles as

venn3_unweighted(...)

(with default subset_areas, which happen to be (1,1,1,1,1,1,1)).

After all, given that venn3_circles does not produce any actual labels for the diagrams, there is no point to differentiate between "weighted" and "unweighted" here. "Unweighted" is just one possible option for area sizes (i.e. one type of weighting).

aldantas commented 6 years ago

Yes, you are correct, thank you!

This is way simpler and was right in front of my nose hahahaha.

I got confuse because in my real case I was using sets of data to draw the diagram. That's why I thought that there could be an wraper for drawing the unweighted circles. But indeed, it is not needed, but perhaps this use case could me mentioned in the README.