The Gestalt principle of similarity states that if proximity is constant and the Figure/Ground does not influence perceptual contrasts, then we will perceive objects to be grouped according to the similarity in their retinal variables.
Similarity in retinal variables
It is retinal variables that define similarity, that may be in terms of colour hue, colour value, size, shape, orientation, texture or motion.
I present here three examples of how similarity can be used to perceive groupings. All three examples present the same pseudo-data, which is visualised using the point implantation as in a scatter graph. The pseudo-data is designed to maintain a constant distance between neighbouring coordinates thus eliminating the effect of proximity.
The first example uses the retinal variable of colour hue to encode groupings. Notice how easily and immediately we can perceive the formation of groupings that share the same hue. And the moment we perceive these distinguishing groups we seem to ignore all other data (in grey colour) which instead is now perceived as part of the Ground:
Using the same data and point implantation, I now form the same groupings using the retinal variable of colour value, using shades of grey:

The groupings may be less easy to discern but they are still noticeable and distinct. As a third example, consider the retinal variable of orientation. The data is still the same but the point implantation is not encoded using vertical lines, and I shift the angle of line to form groupings:

Orientation is a powerful retinal variable that far more recognisable than colour value. It is probably the most underestimated retinal variable.
The principle of similarity is typically be used to encode categorical variation in data graphs, but can also be used to match identification information.
However, it must be emphasised that similarity is only a secondary stimuli and that the Figure/Ground and proximity are far more powerful principles for perceptual organisation.