Function to visualize grids