Answer: when it's a castor oil plant. See, Jonah is sitting under a qiqayon, and that's a hapax legomenon, and I don't say that only because I really like the phrase hapax legomenon. The meaning of the word has long confused translators, and mendel pointed me to a whole essay about it, of which the abstract is as follows:
The fast-growing plant referred to in the biblical Book of Jonah is most often translated into English as “gourd.” However, this is a mistranslation that dates to the appended Septuagint, the Greek translation of the Hebrew Bible, in which the Hebrew word qiqayon (castor, Ricinus communis, Euphorbiaceae) was transformed into the somewhat similar-sounding Greek word kolokynthi (colocynth, Citrullus colocynthis). In translation of the Greek into Latin, kolokynthi became the similar-sounding cucurbita (gourd). This is reflected in early iconography, the plant most often depicted being a long-fruited Lagenaria siceraria (bottle or calabash gourd), a fast-growing climber.
About that word, qiqayon. The essay says it's "derived from ancient Egyptian," though what it doesn't say is that the Egyptian word for that same plant is kiki. I mention this not for any genuinely interesting reason but because when I was a kid I pored obsessively over those name-meanings books and one of them gave the meaning of the name Kiki as "a medicinal plant." I remember thinking that that was kind of a weird thing for a name to mean. Little did I know that it was a specific medicinal plant and that the word would come back into my life decades later. But the castor oil plant isn't only medicinal: castor beans, from which the oil is extracted, are full of highly poisonous ricin. Is that another reason God sent the quick-growing qiqayon to shade his angry prophet? Because virtue is hidden in its poisonous fruit, as it was hidden in the people of Nineveh?
Now, about the plant itself: it is also called palma Christi, palm of Christ, because its leaves look like big hands. I imagine some commentators have called that foreshadowing, though I couldn't find any of them just now when I did a search. (I don't know how long it's been called that, though; maybe it's a recent name that no one wants to retcon into the story because that would be cheating. Obviously it can't have been called that in Jonah's time.) Jesus will call himself "something greater than Jonah" in a few hundred years. In the sense that he wants people to repent and be saved, and preaches forgiveness, and tells his followers to suck it up if they think they deserve salvation more than others, because no one deserves it and yet anyone who asks can have it -- in those ways Jesus certainly is greater than Jonah, and it's nice narratively to think that he is secretly present here as a humble and useful tree. I identify more with the angry dude under the tree, though. I guess neither of us is very Christlike.