Similarity is a gestalt concept the refers to the visual tendency to group shapes together if they visually resemble each other. The shapes do not have to be completely identical. The group will generally be perceived as a single unit. Typically, similarity also requires some amount of proximity.

Similarity creating five groups.

Gris, Juan. Still Life with Oil Lamp. 1912.

Similarity of color creating one group.

Hopper, Edward. Nighthawks. 1942.

The figures highlighted in yellow are in close proximity but do not seem to create a group because they lack good similarity.
The figures highlighted in green are in close proximity and exhibit good similarity.