The relationship between star color and mass is mainly determined by the star's luminosity and effective temperature. In general, more massive stars are more luminous and have higher surface temperatures. This is because more massive stars have a stronger gravitational force, causing their cores to be denser and hotter. As a result, they produce more energy through nuclear fusion reactions and emit more light.
Therefore, the higher the mass of a star, the hotter and bluer it tends to be. For instance, O-type and B-type stars are very massive and hot, emitting primarily blue light. On the other hand, M-type stars are the least massive and coolest, appearing red or orange.
The Hertzsprung-Russell diagram (H-R diagram) visually illustrates the relationship between star color, mass, and other stellar properties. On the H-R diagram, stars are plotted according to their luminosity on the vertical axis and their effective temperature on the horizontal axis. The different regions of the diagram correspond to different star types based on their color and mass.
It's important to note that while star color is primarily influenced by temperature, other factors can affect the observed color, such as the star's age, chemical composition, and presence of dust and gas in the surrounding environment.