Errata
Thank You:

Many thanks to all the fine gold goblins who have milled thousands of herbs to get the pigment ratios. Without them, having TSM imports for material prices would not be possible.

The Calculations

For format of each pigment is in two sections:

The First Half

min(SmartAvgBuy, DBMarket, 5 * min()) Checks the average purchase price of your current inventory against the market value of the pigment, taking whichever of the two is less gold. The 5 * min() is the second half of the calculation.

The Second Half

This is a bit complex. We need to normalize the cost of each pigment in herbs to a single herb. Then adjust the herb's value by the ratio of each pigment produced. Next, compare all the adjusted herbs that can possibly produce a pigment to themselves, finding the least expensive herb. Finally, multiply the cost by 5, as it takes 5 of any herb to produce a pigment. Somewhere, we also compare your SmartAvgBuy to DBMarket of each herb, because you might have herbs and you might buy the herbs lower than market value. The shorthand version is 5 * min(min(SmartAvgBuy(i:itemID), DBMarket(i:itemID) / ratio), next, next) where itemID is each herb's itemID.

All Together

Following along, that would mean each pigment would be in this format: min(SmartAvgBuy, DBMarket, 5 * min(min(SmartAvgBuy(i:itemID), DBMarket(i:itemID) / ratio), next, next)) and I hope I have the open and close parenthesis correct!

Where To Use The Calculations

Open the crafting UI with TradeSkillMaster, Gathering tab, Materials tab, find the pigment, click on it, and change the existing (probably min(dbmarket, crafting, vendorbuy, convert(dbmarket))) text to the matching pigment calculation below.

What This Does

There is a bug(?) in Blizzard's Mass Milling API, where it incorrectly returns 1 of the herb that was milled, effectively saying it takes 20 herbs to use the skill, but you get 1 back, for a net 19 herbs used. Obviously, this is not true. The calculations below work around this bug by adjusting the material costs of the pigments, removing crafting and convert() from the equations.

So why not simply edit each herb and remove the offending price sources? Because there is nothing wrong with the herb prices, and you lose out on possibly "crafting" the herbs from leaves and lesser materials which might be more cost effective. This method, adjusting the pigments, is more accurate.

What You Wanted

Finally, here they are, from Shadowlands to Warlords of Draenor. The earlier expansions do not have Mass Milling, and do not require customized material prices.

Shadowlands
Umbral Pigment

min(SmartAvgBuy, DBMarket, 5 * min((min(SmartAvgBuy(i:169701), DBMarket(i:169701)) / 0.140), (min(SmartAvgBuy(i:168589), DBMarket(i:168589)) / 0.204), (min(SmartAvgBuy(i:168583), DBMarket(i:168583)) / 0.194), (min(SmartAvgBuy(i:168586), DBMarket(i:168586)) / 0.092), (min(SmartAvgBuy(i:170554), DBMarket(i:170554)) / 0.097), (min(SmartAvgBuy(i:171315), DBMarket(i:171315)) / 0.263), (min(SmartAvgBuy(i:187699), DBMarket(i:187699)) / 0.243)))

Luminous Pigment

min(SmartAvgBuy, DBMarket, 5 * min((min(SmartAvgBuy(i:169701), DBMarket(i:169701)) / 0.150), (min(SmartAvgBuy(i:168589), DBMarket(i:168589)) / 0.091), (min(SmartAvgBuy(i:168583), DBMarket(i:168583)) / 0.096), (min(SmartAvgBuy(i:168586), DBMarket(i:168586)) / 0.202), (min(SmartAvgBuy(i:170554), DBMarket(i:170554)) / 0.205), (min(SmartAvgBuy(i:171315), DBMarket(i:171315)) / 0.232), (min(SmartAvgBuy(i:187699), DBMarket(i:187699)) / 0.258)))

Tranquil Pigment

min(SmartAvgBuy, DBMarket, 5 * min((min(SmartAvgBuy(i:169701), DBMarket(i:169701)) / 0.005), (min(SmartAvgBuy(i:168589), DBMarket(i:168589)) / 0.004), (min(SmartAvgBuy(i:168583), DBMarket(i:168583)) / 0.005), (min(SmartAvgBuy(i:168586), DBMarket(i:168586)) / 0.004), (min(SmartAvgBuy(i:170554), DBMarket(i:170554)) / 0.004), (min(SmartAvgBuy(i:171315), DBMarket(i:171315)) / 0.305), (min(SmartAvgBuy(i:187699), DBMarket(i:187699)) / 0.496)))

Battle for Azeroth
Viridescent Pigment

min(SmartAvgBuy, DBMarket, 5 * min((min(SmartAvgBuy(i:152510), DBMarket(i:152510)) / 0.328), (min(SmartAvgBuy(i:152511), DBMarket(i:152511)) / 0.132), (min(SmartAvgBuy(i:152508), DBMarket(i:152508)) / 0.132), (min(SmartAvgBuy(i:152509), DBMarket(i:152509)) / 0.132), (min(SmartAvgBuy(i:152505), DBMarket(i:152505)) / 0.130), (min(SmartAvgBuy(i:152506), DBMarket(i:152506)) / 0.131), (min(SmartAvgBuy(i:152507), DBMarket(i:152507)) / 0.134)))

Crimson Pigment

min(SmartAvgBuy, DBMarket, 5 * min((min(SmartAvgBuy(i:152510), DBMarket(i:152510)) / 0.316), (min(SmartAvgBuy(i:152511), DBMarket(i:152511)) / 0.316), (min(SmartAvgBuy(i:152508), DBMarket(i:152508)) / 0.312), (min(SmartAvgBuy(i:152509), DBMarket(i:152509)) / 0.316), (min(SmartAvgBuy(i:152505), DBMarket(i:152505)) / 0.316), (min(SmartAvgBuy(i:152506), DBMarket(i:152506)) / 0.315), (min(SmartAvgBuy(i:152507), DBMarket(i:152507)) / 0.318)))

Ultramarine Pigment

min(SmartAvgBuy, DBMarket, 5 * min((min(SmartAvgBuy(i:152510), DBMarket(i:152510)) / 0.827), (min(SmartAvgBuy(i:152511), DBMarket(i:152511)) / 0.825), (min(SmartAvgBuy(i:152508), DBMarket(i:152508)) / 0.825), (min(SmartAvgBuy(i:152509), DBMarket(i:152509)) / 0.822), (min(SmartAvgBuy(i:152505), DBMarket(i:152505)) / 0.825), (min(SmartAvgBuy(i:152506), DBMarket(i:152506)) / 0.826), (min(SmartAvgBuy(i:152507), DBMarket(i:152507)) / 0.827)))

Maroon Pigment

min(SmartAvgBuy, DBMarket, 5 * min((min(SmartAvgBuy(i:168487), DBMarket(i:168487)) / 0.598)))

Legion

Milling herbs from this expansion results in extra Yseralline Seeds, which can be milled. Therefore, I must subtract the market value of the seed multiplied by the ratio of seeds you get from milling other herbs from the value of the other herbs. In other words, the value of each other herb is reduced by the seeds you get as a byproduct, in turn meaning you need less of the other herbs.

The ratios used are adjusted for Nightmare Pods, which contain pigments.

Roseate Pigment

min(SmartAvgBuy, DBMarket, 5 * min((min(SmartAvgBuy(i:128304), DBMarket(i:128304)) / 0.199), ((min(SmartAvgBuy(i:124101), DBMarket(i:124101)) / 0.715) - (DBMarket(i:128304) / 0.07)), ((min(SmartAvgBuy(i:124102), DBMarket(i:124102)) / 0.715) - (DBMarket(i:128304) * 0.07)), ((min(SmartAvgBuy(i:124104), DBMarket(i:124104)) / 0.715) - (DBMarket(i:128304) / 0.07)), ((min(SmartAvgBuy(i:124103), DBMarket(i:124103)) / 0.715) - (DBMarket(i:128304) / 0.07)), ((min(SmartAvgBuy(i:124105), DBMarket(i:124105)) / 0.354) - (DBMarket(i:128304) / 0.04)), ((min(SmartAvgBuy(i:124106), DBMarket(i:124106)) / 0.42)), ((min(SmartAvgBuy(i:151565), DBMarket(i:151565) / 0.405) - DBMarket(i:128304) / 0.02))))

Sallow Pigment

min(SmartAvgBuy, DBMarket, 5 * min((min(SmartAvgBuy(i:128304), DBMarket(i:128304)) / 0.199), ((min(SmartAvgBuy(i:124101), DBMarket(i:124101)) / 0.076) - (DBMarket(i:128304) / 0.07)), ((min(SmartAvgBuy(i:124102), DBMarket(i:124102)) / 0.076) - (DBMarket(i:128304) / 0.07)), ((min(SmartAvgBuy(i:124104), DBMarket(i:124104)) / 0.076) - (DBMarket(i:128304) / 0.07)), ((min(SmartAvgBuy(i:124103), DBMarket(i:124103)) / 0.076) - (DBMarket(i:128304) / 0.07)), ((min(SmartAvgBuy(i:124105), DBMarket(i:124105)) / 0.038) - (DBMarket(i:128304) / 0.04)), ((min(SmartAvgBuy(i:124106), DBMarket(i:124106)) / 0.446)), ((min(SmartAvgBuy(i:151565), DBMarket(i:151565) / 0.042) - DBMarket(i:128304) / 0.02))))

Warlords of Draenor
Cerulean Pigment

min(SmartAvgBuy, DBMarket, 5 * min((min(SmartAvgBuy(i:109127), DBMarket(i:109127)) / 0.422), (min(SmartAvgBuy(i:109125), DBMarket(i:109125)) / 0.422), (min(SmartAvgBuy(i:109129), DBMarket(i:109129)) / 0.422), (min(SmartAvgBuy(i:109128), DBMarket(i:109128)) / 0.422), (min(SmartAvgBuy(i:109124), DBMarket(i:109124)) / 0.422), (min(SmartAvgBuy(i:109126), DBMarket(i:109126)) / 0.422)))

EDIT

I have updated and corrected the calculations based on comments below. Thank you everybody for finding my late night typos. Sorry if the former calculations are messing up your prices.

Finis

That's everything I could find. If you like what I do on Reddit, you can access my full TSM groups and operations on Patreon. Thank you, and enjoy milling!