Please see the code below:
import matplotlib.pyplot as plt
to_utility = [-3.4000000000000004, -2.6999999999999993, -0.9000000000000004, 1.8000000000000007, -1.0999999999999996,
-1.6999999999999993, 0.6999999999999993, 5.300000000000001, 0.1999999999999993, 2.3999999999999986, 2.5,
1.3999999999999986, -3.6999999999999993, -8.8, -6.600000000000001, -9.600000000000001, -11,
-7.800000000000001, -8.4, -8.9, -11.7, -7.300000000000001, -8.9, -4.9]
shifted = 6.652632153034208
curve_max = max(to_utility)
curve_min = min(to_utility)
upper_shift_line = [curve_max - shifted] * len(to_utility)
fig = plt.figure()
ax1 = fig.add_subplot(111)
ax1.set_title('To Utility Curve')
ax1.set_ylim([curve_min, curve_max])
ax1.plot(range(len(to_utility)), to_utility, upper_shift_line)
ax1.fill_between(range(len(to_utility)), to_utility, upper_shift_line, where=to_utility > upper_shift_line,
interpolate=True)
plt.show()
Somehow the area is not filled, but if I remove the where= condition, it will work.