I am generating 4 rectangles using ax.add_patch. I want to connect these rectangles using single lines as shown in the expected output.
import matplotlib as mpl
import matplotlib.pyplot as plt
from matplotlib.patches import Rectangle
fig,ax = plt.subplots(1)
n=2
for i in range(0,n):
for j in range(0,n):
rect = mpl.patches.Rectangle((200+200*i,200+200*j),10*n, 10*n, linewidth=1, edgecolor='black', facecolor='black')
ax.add_patch(rect)
ax.set_xlim(left = 0, right = 220*n)
ax.set_ylim(bottom = 0, top = 220*n)
plt.show()
The current output is
The expected output is



