I have this demo code which generates colored rectangles with Matlplotlib. After several hours searching everywhere, I still do not understand how to visualize the intersection between 2 rectangles or more in a different color. Thank you very much.
import matplotlib
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111)
rect1 = matplotlib.patches.Rectangle((-675, -374),
744, 412,
color ='green')
rect2 = matplotlib.patches.Rectangle((-48, -454),
116, 491,
color ='blue')
rect3 = matplotlib.patches.Rectangle((-1009, -189),
1074, 225,
color ='yellow')
ax.add_patch(rect1)
ax.add_patch(rect2)
ax.add_patch(rect3)
plt.xlim([-1100, 1100])
plt.ylim([-1100, 1100])
plt.show()