Above a certain temperature a local play by either player normally entails a loss; the vertical mast is colored black there to indicate that. Lower down, the mast may be colored: blue where Black can play locally without loss, red where White can, and purple where both can.
The most common colored mast occurs with (theoretical) sente positions. Just above the base of a sente mast the mast has the color of the sente player. That coloring indicates that the sente player has the privilege of making the play with sente in that temperature range (as a rule).
Colored masts are related to ambiguous positions, i.e. those that are not clearly either sente or gote. Just below the base of the mast of a sente position the wall of the sente player is vertical, which indicates that the opponent will reply to the sente play. Some ambiguous positions have such a vertical wall, but the mast just above the base is black or purple, so that there is no privilege. On the other hand, the mast of some ambiguous positions have a colored mast that indicates privilege, but just below the base of the mast each wall angles in the direction of the player, which indicates that the opponent does not reply to a local play (gote).
Purple masts normally indicate miai positions, where either player can play, but gains nothing, on average, from doing so. (Inclined sections of a ko mast are purple, as well.) Such vertical purple masts indicate a mutual ko threat, where either player may make a local play as a ko threat and thereby take away their opponent’s threat.