#Colors.
c = ['#440154FF', '#3B528BFF', '#21908D', '#5EC962', '#FDE725']
xs = [i/1000 for i in range(1001)]
k4 = [x**4 for x in xs]
k5 = [4 * x**4 *(1-x) for x in xs]
k6 = [10 * x**4 *(1-x)**2 for x in xs]
k7 = [20 * x**4 *(1-x)**3 for x in xs]
c7 = [20 * x**3 *(1-x)**4 for x in xs]
c6 = [10 * x**2 *(1-x)**4 for x in xs]
c5 = [4 * x *(1-x)**4 for x in xs]
c4 = [(1-x)**4 for x in xs]
kc7 = [20 * x**3 *(1-x)**3 for x in xs]
def gamesPlot(option) :
sns.set()
#Plot.
fig = plt.figure(figsize = (12.5, 7.5))
if option == 'Fiddler1' :
ax = fig.add_subplot(xlim = (0, 1), ylim = (0, 0.6))
xticks = [x/10 for x in range(11)]
yticks = [y/10 for y in range(7)]
a = 1
elif option == 'Fiddler2' :
ax = fig.add_subplot(xlim = (0.45, 0.766667), ylim = (0.15, 0.35))
xticks = [x/20 for x in range(9, 16)]
yticks = [y/20 for y in range(3, 8)]
a = 0.5
else :
ax = fig.add_subplot(xlim = (0.55, 0.766667), ylim = (0.205, 0.335))
xticks = [x/20 for x in range(11, 16)]
yticks = [y/20 for y in range(4, 8)]
a = 1
#Title.
ax.set_title("Swept?", fontsize = 24)
#x-axis.
ax.set_xlabel("Probability Knicks Win a Game (p)", fontsize = 18, labelpad = 10)
plt.xticks(ticks = xticks)
plt.xticks(rotation = 45)
#y-axis.
ax.set_ylabel("Probability Knicks Win the Series", fontsize = 18)
plt.yticks(ticks = yticks)
ax.tick_params(axis = 'both', labelsize = 16)
sx = 3/4
sy = 81/256
if option != 'EC' :
y = [k4, k5, k6, k7]
labels = ["Knicks will win in " + str(w) + " games" for w in range(4, 8)]
for i in range(4) :
ax.plot(xs, y[i], lw = 3, c = c[i], label = labels[i], alpha = a, zorder = 3)
if option == 'Fiddler2' :
ax.plot(xs[600:751], y[1][600:751], lw = 5, c = c[1], zorder = 3)
text = [("Q", (1/2, 5/32)),
("R", (3/5, 648/3125)),
("S", (sx, sy)),
("T", (0.552786, 0.1670338)),
("U", (0.683772, 0.2185978)),
("V", (0.631597, 0.1591328))]
for t in text :
plt.scatter(t[1][0], t[1][1], lw = 3, c = 'k', zorder = 4)
plt.annotate(text = t[0],
xy = t[1],
c = 'k',
size = 20,
ha = 'right',
va ='bottom',
zorder = 4)
else :
wx = 0.676582
wy = 0.209548
y = [k4, k5, kc7]
labels = ["Knicks will win in 4 games",
"Knicks will win in 5 games",
"Series will go to 7 games"]
for i in range(2) :
ax.plot(xs, y[i], lw = 5, c = c[i], label = labels[i], zorder = 3)
ax.plot(xs, y[2], lw = 5, c = c[3], label = labels[2], zorder = 3)
#W.
plt.scatter(wx, wy, lw = 3, c = 'k', zorder = 4)
#p7.
ax.plot([0.6, 0.6, 0.6, 0.676], [wy+0.005, wy-0.005, wy, wy], lw = 1.5, c = c[3], zorder = 2)
#p4.
ax.plot([0.6771, sx, sx, sx], [wy, wy, wy-0.005, wy+0.005], lw = 1.5, c = c[0], zorder = 2)
text = [("W", (wx, wy), 'k', 20),
("p7", (0.638, wy), c[3], 16),
("p4", (0.724, wy), c[0], 16)]
for t in text :
plt.annotate(text = t[0],
xy = t[1],
c = t[2],
size = t[3],
ha = 'center',
va = 'bottom',
zorder = 4)
ax.legend(fontsize = '14', loc = 'upper left')
fig.savefig("2025.05.09" + str(option) + ".png", bbox_inches = 'tight')