まし is usually used to mean "preferable" in the "less bad" sense,
i.e. you're choosing the lesser of two evils. ぐらいなら reinforces
this point, i.e. 魚を食べるぐらいなら飢えたほうがましだ If I had to go as far as
eating fish, starving would be less bad. ぐらい can come after
nouns as well, but with this specific nuance, it is not often
used after nouns. So we could say 恥をかくぐらいなら死んだほうがましだ Dying is
preferable to facing disgrace However, if we're using the noun
恥, it would be more natural to rephrase to よりも (or よりは)
恥よりも死のほうがましだ Death is preferable to disgrace By the way, your
example sentence is comparing a noun to a verb, 恥 and 死ぬ. While
maybe not exactly wrong, I feel rewriting 死ぬ to the noun 死
sounds better. Beware that ぐらい can also be used in the opposite
sense, to reinforce that something is easy or small (like
"only"). In this sense, it's used after nouns as well
ちょっと待つぐらいならいい I don't mind waiting (if it's only) for a bit
ケーキ五個ぐらいなら食べられる If it's only 5 cakes, I can eat them