Color and temperature are related by the famous Planck, black body formula shown here in a NASA-Webb Space Telescope illustration. Actually, the formula gives the intensity of a black body at any wavelength given its temperature. The wavelength where the peak of this curve occurs is determined by the temperature of the black body. You then have to relate this peak wavelength of emission to how the human eye identifies color in the visual part of the electromagnetic spectrum. For example, the wavelength of peak emission is
2897
Wavelength (micrometers) = ------------------
Temperature (K)
so that for the Sun with a temperature of 5700 K, the peak of the black body curve occurs at 2897/5700 = 0.51 micrometers or 5100 Angstroms. A cool M-type star can have T = 2500 K so their peak emission occurs at 1.16 micrometers in the deep or ‘far’ red part of the spectrum.