Spaces:
Runtime error
Runtime error
hedtorresca
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,6 @@
|
|
1 |
import gradio as gr
|
2 |
import matplotlib.pyplot as plt
|
3 |
-
from
|
4 |
-
from matplotlib_venn import venn3
|
5 |
from io import BytesIO
|
6 |
from PIL import Image
|
7 |
|
@@ -57,13 +56,8 @@ def calculate_probabilities(A, B, C, AB, AC, BC, ABC, U):
|
|
57 |
return formatted_probs
|
58 |
|
59 |
def plot_venn(A, B, C, AB, AC, BC, ABC, U):
|
60 |
-
plt.figure(figsize=(
|
61 |
|
62 |
-
# Dibujar el conjunto universal como un rectángulo
|
63 |
-
ax = plt.gca()
|
64 |
-
ax.add_patch(Rectangle((0, 0), 1, 1, fill=None, edgecolor='black', linewidth=2))
|
65 |
-
|
66 |
-
# Dibujar el diagrama de Venn
|
67 |
subsets = {
|
68 |
'100': A - AB - AC + ABC,
|
69 |
'010': B - AB - BC + ABC,
|
@@ -74,13 +68,8 @@ def plot_venn(A, B, C, AB, AC, BC, ABC, U):
|
|
74 |
'111': ABC
|
75 |
}
|
76 |
venn = venn3(subsets=subsets, set_labels=('A', 'B', 'C'))
|
|
|
77 |
|
78 |
-
# Mostrar la cantidad fuera de A, B y C si no coincide con U
|
79 |
-
suma_subconjuntos = A + B + C - AB - AC - BC + ABC
|
80 |
-
if U > suma_subconjuntos:
|
81 |
-
faltante = U - suma_subconjuntos
|
82 |
-
plt.text(0.5, 0.9, f"Fuera de A, B y C: {faltante}", horizontalalignment='center', fontsize=12, bbox=dict(facecolor='white', alpha=0.5))
|
83 |
-
|
84 |
plt.title(f"Diagrama de Venn con U = {U}")
|
85 |
|
86 |
buf = BytesIO()
|
|
|
1 |
import gradio as gr
|
2 |
import matplotlib.pyplot as plt
|
3 |
+
from matplotlib_venn import venn3, venn3_circles
|
|
|
4 |
from io import BytesIO
|
5 |
from PIL import Image
|
6 |
|
|
|
56 |
return formatted_probs
|
57 |
|
58 |
def plot_venn(A, B, C, AB, AC, BC, ABC, U):
|
59 |
+
plt.figure(figsize=(10, 10))
|
60 |
|
|
|
|
|
|
|
|
|
|
|
61 |
subsets = {
|
62 |
'100': A - AB - AC + ABC,
|
63 |
'010': B - AB - BC + ABC,
|
|
|
68 |
'111': ABC
|
69 |
}
|
70 |
venn = venn3(subsets=subsets, set_labels=('A', 'B', 'C'))
|
71 |
+
venn_circles = venn3_circles(subsets=subsets, linewidth=1.0)
|
72 |
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
plt.title(f"Diagrama de Venn con U = {U}")
|
74 |
|
75 |
buf = BytesIO()
|