konstantint / matplotlib-venn

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

plt.show() doesn't work in conditional statements #46

Closed felixlee0530 closed 4 years ago

felixlee0530 commented 4 years ago

I am using matplotlib-venn to plot either a 2 or 3 circled Venn diagram.

This is the simple code I created. It will output with a plot of 2 or 3 circled diagram based on the number I will enter. I checked that individual venn2 or venn3 plots work fine, shown in separate GUIs.

from matplotlib import pyplot as plt
from matplotlib_venn import venn3, venn3_circles, venn2, venn2_circles

decision = input("Please enter a number for the number of circles: ")

if decision == 3:
    v1 = venn3(subsets=(1, 1, 1, 1, 1, 1, 1), set_labels=('A', 'B', 'C'))
    for idx, subset in enumerate(v1.subset_labels):
        v1.subset_labels[idx].set_visible(False)
    c1 = venn3_circles(subsets=(1, 1, 1, 1, 1, 1, 1), linestyle='solid')
    plt.title("THREE CIRCLE VENN DIAGRAM")
    plt.figure(figsize=(5, 5))
    plt.show(v1)
if decision == 2:
    v2 = venn2(subsets=(1, 1, 1), set_labels=('A', 'B'))
    for idx, subset in enumerate(v2.subset_labels):
        v2.subset_labels[idx].set_visible(False)
    c2 = venn2_circles(subsets=(1, 1, 1), linestyle='solid')
    plt.title("TWO CIRCLE VENN DIAGRAM")
    plt.figure(figsize=(5, 5))
    plt.show(v2)

However, when I run the code and enter the number, the code just quits without showing the GUI plot. How should I fix this code to work properly?

felixlee0530 commented 4 years ago

Sorry, it was a really simple mistake. I did not add int in front of input.