When I was a little boy I thought that taxis could only be yellow and black. Later I discovered that in most cities they are white, and many of them have a colored stripe so you can detect them. Even later I learned that there are other cities where taxis share colors with ours, as Buenos Aires, Montevideo and Mumbai, but they are an rare.
In 1906 the first motorized taxis appeared in Barcelona, with one single station in La Rambla, and they coexisted with the old horse carriages. Motorized vehicles finally prevailes and at one point it was decided that they should show a yellow, blue or red strip in the back, depending on the rate they charged. In 1934, though, it was necessary to organize the sector, and rates and colors were unified, so yellow was adopted as a common hallmark. this is the origin of the color of our taxis, with yellow doors while the rest is basically black.
As a curiosity, let me tell you that the person who took all this measures was Jaume Vachier, a municipal councilor, who tried to arrange the chaotic traffic of Barcelona in the 1920's, and planned underground car parks, promoted the first crosswalk of the city (at Balmes-Provença) and also the first traffic light at the same intersection.
Currently there is an EU directive that suggests that taxis should be painted in ecru color, as they are in Germany. For the time being noone is paying attention to it. Can you imagine the disappearance of the yellow and black taxis of Barcelona?