This post shows how to dye a rainbow on a single piece of fabric using three dip vat baths of dye, with some inexpert digressions on color mixing

The goal: a rainbow striped item using three color baths:yellow, magenta, and cyan (turquoise). The demonstration shown here uses commerical acid dyes on silk and silk/wool blend scarves. You will need to find the dye mixes listed as "primaries" of the three colors to get the same results.
Dyes follow subtractive color mixing - an undyed white item reflects all visible wavelengths. When you add dye, you add a chemical which now selectively absorbs some wavelengths of light, resulting in a color. The CMY (cyan-magenta-yellow) color set is the primary set for subtractive color mixing. The rules of secondary mixing with these colors are as follow:
equal parts C+Y = green
equal parts M+Y = red
equal parts C+M = blue
So this color set is sort of orthogonal to the RGB set that is familiar from computer screens (which mix additively).
The tertiary color mixing is:
a little C + more Y = yellow-green
a lot of C + a little Y = blue-green
a little C + more M = purple
a lot of C + a little M = blue-violet
a little Y + more M = red-orange
a lot of Y + a little M = orange
So, we set up our dye baths to do three dips. The first dip here is in the Cyan (turquoise) bath. Prepare the bath, wet the fabric, and dip the fabric to control exposure to the dye. There should be a saturated region of cyan at the lower section of the fabric, with only light exposure to cyan at the end of the scarf, and tailing off into the middle.

Next, the magenta bath. Dip the turquoise end of the fabric only up to the section that you want to be blue, leaving some turquoise above that. Also dip the top end of the fabric, saturated at the end, and tailing off towards the middle. Leave an undyed section in the center.
Finally, the yellow bath. Dip only the center of the fabric, from the area that you want to be green to the area that you want to be red. This results in a scarf with the color sequence: magenta-red-orange-yellow-green-turquoise-blue-purple.
Here is a diagram showing coverage for each of the baths. You can dye the baths in any order.

You can also do variations. This variation does not have purple at the end, as the turquoise dye bath is full strength at the end of the fabric , tailing off toward the center.

This combination results like this:

The benefits of trying this are 1) to see the full range of colors that you can mix with your choice of dyes and fabric, using only the primaries, and 2) to achieve a rainbow that has color gradations, rather than using a separate dye for each color.