If I remember correctly (sorry it’s been a while), the size of the star determines its colour, and the data suggests that the colour of stars fits nicely into the mass of a star (ie you’ll never see a star of X color thats Y kg)
The rule is violated in all sorts of fun and interesting ways. There's white dwarfs, for one, then stars with varying levels of metallicity. Stars can merge, which does strange things to their position on the Hertzsprung–Russell diagram. There's oddball combinations like a red giant with a neutron star that has sunk into its core, called a Thorne–Żytkow Object!
Not to mention variable stars, novae, occultation by dust clouds, etc.