How to remove grid lines to distinguish between lattice sites using Python?

87 Views Asked by At

The result for certain calculations when drawn using python matshow

gives the figure as .

Is there any way to draw lines

like a border between the various colors like in this

like a border between the various colors like in this figure? This is a grid n X n that looks like this initially.

that looks like this initially

Each square has 4 small squares(lattices) within it. i.e in the case of the first square, it has (0,0), (1,0), (0,1) and (1,1) indices occupied by the same number say 0 and the next square has (0,3), (0,3), (1,3) and (1,3) indices occupied by a different number say 1.

This is resulting in a different color. After subjecting it to some mathematical operations I got the first image. Now I want to distinguish between these colors as in figure 2. Is there a way to do this? Any leads would be appreciated!

1

There are 1 best solutions below

0
On

You could iterate over each cell in the final grid to compare its color with its N, S, E, W neighbors, and draw a line segment corresponding to the border, when the condition is met, and not when the cells share the same color.

I would have provided a small sample code, but you did not explain how your cells and grids are represented; however, this is rather straightforward code that you can probably write.