import matplotlib.pyplot as plt import numpy as np # Define grid dimensions rows, cols = 4, 9 # 4 rows and 9 columns, matching the layout in the image # Create a figure and axis fig, ax = plt.subplots(figsize=(9, 4)) # Draw the grid for x in range(cols + 1): ax.axvline(x, color='black', linewidth=1) for y in range(rows + 1): ax.axhline(y, color='black', linewidth=1) # Add cells and data ax.set_xlim(0, cols) ax.set_ylim(0, rows) # Example: Add text to cells cell_data = {(0, 0): "Item1", (1, 1): "Item2", (2, 3): "Item3"} for (row, col), text in cell_data.items(): ax.text(col + 0.5, rows - row - 0.5, text, ha='center', va='center', fontsize=12) # Remove axes for a cleaner look ax.axis('off') # Show the grid plt.tight_layout() plt.show()