pythonmatplotlibdata-visualizationvenn-diagrammatplotlib-venn

How do you remove data labels in matplotlib_venn?


Not the text labels outside the circles, I can remove them by changing them to empty strings.

I mean the actual numbers on the circles showing the value of each patch. I can't find how to remove these. Is there a way? Or is there a way to change the colour of them, so that I can just blend them into the background?


Solution

  • Borrowing the "base-code" from this question I think I have come to a solution for you:

    from matplotlib import pyplot as plt
    from matplotlib_venn import venn3, venn3_circles
    set1 = set(['A', 'B', 'C', 'D'])
    set2 = set(['B', 'C', 'D', 'E'])
    set3 = set(['C', 'D',' E', 'F', 'G'])
    
    out = venn3([set1, set2, set3], ('Set1', 'Set2', 'Set3'))
    for idx, subset in enumerate(out.subset_labels):
        out.subset_labels[idx].set_visible(False)
    
    plt.show(out)
    

    This walks through all of the subset_labels and sets the visibility to False. Effectively removing the text.