Untitled
Anonymous
Plain Text
10/19/2025 8:46 AM
2.2 KB
14
Indexable
Never
import matplotlib.pyplot as plt
from matplotlib_venn import venn3
# Venn Diagram for Question 7 (Magazines A, B, C)
A_only = 12
AB_only = 20
ABC = 30
B_only = 0
C_only = 0
AC_only = 0
# Calculate the people who only read B and C
B_only = 40 - (AB_only + ABC)
C_only = 38 - (ABC + AC_only)
# Draw the Venn Diagram for Question 7
venn7 = venn3(subsets=(A_only, B_only, AB_only, AC_only, ABC, 0, C_only),
set_labels=('A', 'B', 'C'))
venn7_circles = venn7.circles
venn7_circles['A'].set_edgecolor('blue')
venn7_circles['B'].set_edgecolor('red')
venn7_circles['C'].set_edgecolor('green')
plt.title('Venn Diagram for Magazines A, B, and C')
plt.show()
# Venn Diagram for Question 8 (Subjects Maths, Science, French)
Math = 80
Science = 55
French = 58
Math_Science = 45
Math_French = 15
Science_French = 55
All_three = 15
Math_only = Math - (Math_Science + Math_French - All_three)
Science_only = Science - (Math_Science + Science_French - All_three)
French_only = French - (Math_French + Science_French - All_three)
# Draw the Venn Diagram for Question 8
venn8 = venn3(subsets=(Math_only, Science_only, Math_Science, French_only,
Math_French, Science_French, All_three),
set_labels=('Math', 'Science', 'French'))
venn8_circles = venn8.circles
venn8_circles['Math'].set_edgecolor('blue')
venn8_circles['Science'].set_edgecolor('red')
venn8_circles['French'].set_edgecolor('green')
plt.title('Venn Diagram for Subjects: Maths, Science, and French')
plt.show()
# Venn Diagram for Question 9 (History, Geography, Art)
History = 28
Geography = 30
Art = 22
History_only = 6
History_Geography = 15
All_three = 3
Geography_only = Geography - (History_Geography + All_three)
Art_only = Art - (History_Geography + All_three)
History_Art = History_Geography - 3
# Draw the Venn Diagram for Question 9
venn9 = venn3(subsets=(History_only, Geography_only, History_Geography,
Art_only, History_Art, All_three),
set_labels=('History', 'Geography', 'Art'))
venn9_circles = venn9.circles
venn9_circles['History'].set_edgecolor('blue')
venn9_circles['Geography'].set_edgecolor('red')
venn9_circles['Art'].set_edgecolor('green')
plt.title('Venn Diagram for Subjects: History, Geography, and Art')
plt.show()
Editor is loading...
Leave a Comment