When reading descriptions of early railroad equipment, it was obvious the equipment was painted in a wide range of colors, given elaborate trim, or both.
The bean counters put a halt to that when it was time to repaint.
With coal being a common fuel, it does seem to make sense to paint locomotive black to hide the gritty, grimy finish resulting from daily use.
Why did box car red and all of its variations become the common color on wooden rolling stock?
What was the reasoning, if any - i.e, branding, for the use of other colors?