Ah. This old chestnut again...
The basic principle was that bigger rank plaques broadly indicated higher rank and, just occasionally, some plaques were used consistently to indicate similar ranks.
Outside of this, there was, however, absolutely NO specific "scheme" that the wardrobe department followed with any degree of consistency - largely, it was just "whatever looked good at the time," as has been stated above. There is NO clear indicaction of the relative significance of numbers or colors of squares on the plaques - or their relative arrangement. Equally, the so-called "code cylinders" were additionally just decorative elements to the Imperial Officer uniforms, albeit the rule was generally that the more senior the officer, the more "cylinders" they had in their top pockets. If I recall correctly, the use of specific numbers of "cylinders" as secondary rank markings that helped to differentiate between ranks was purely a fan-devized concept, necessary to try to rationalise the inconsistent use of the different sizes/colors of primary rank plaques.
ANY attempt to fully rationalise the Imperial insignia from the original Star Wars trilogy is therefore an exercise in futility and will therefore lead to frustration, compromise and madness...!!
Star Wars has always been interesting in that successive published and fan fiction ideas have crept into the overall accepted canon over the years - but, again, there has been little consistency between these ideas so, rather than helping, it has often succeded only in confusing things further.
Anyone who suggests that they DO know the exact scheme is simply lying. There have been some imaginative attempts at TRYING to rationalise the impossible but all have inherent flaws and inconsitencies. There have been some pretty good attempts though.
If I was to try to do it myself (which I won't - I don't have the time at the moment!) I'd have to suggest starting from a simple numerical premise, accepting that it will be impossible to rationalise all the on-screen insignia, and would focus on creating a rank insignia scheme that was at least internally consistent, probably using just red and blue squares and then adding in the gold squares to indicate seniority at a certain level - perhaps they are more about additionally identifying an individual's ROLE rather than their absolute RANK per se...? A certain degree of variation may be acceptable for the Stormtroopers as they seem to exist as a separate force with their own internal structure.