I am generating rectangular patches as shown below but some rectangles have different sizes even though I am using a constant dimension. I want all rectangles to be of the same size. How do I fix this?
import matplotlib as mpl
import matplotlib.pyplot as plt
from matplotlib.patches import Rectangle
from matplotlib.colors import Normalize
from matplotlib import cm
fig,ax = plt.subplots(1)
n=67
i=1
j=5
Factor=1000
for i in range(0, n):
rect = mpl.patches.Rectangle((Factor+Factor*i, Factor+Factor*j), 10*n, 10*n, linewidth=1, edgecolor='black', facecolor='black')
ax.add_patch(rect)
ax.set_xlim(left = 0, right = Factor*1.1*n)
ax.set_ylim(bottom = 0, top = Factor*1.1*n)
plt.show()

figsizein subplots,fig,ax = plt.subpots(1, figsize=(30,10)). If still have issue, please let us know your python/matplotlib version.Rectangle(..., snap=False)to prevent matplotlib from snapping lines to pixel position. For very short distances, this won't be 100% perfect, but it will look more evenly.