Quite simply, when a character gives another character a cute or endearing nickname because the two are either as close as True Companions, or the namer is interested romantically in the namee. The nickname may not be well-received by the one being named, as they find it insulting or embarrassing, but in the mind of the name-giver it's sweet and/or thoughtful. The formal term for an affectionate nickname is a "hypocorism".
In short, it's a pet name. Expect The Nicknamer to dole these out a lot.
Sub-Trope of In-Series Nickname. Compare Insult of Endearment. Contrast Terms of Endangerment, where an enemy uses a superficially affectionate nickname in an irritating or disturbing manner.
See Significant Name Shift, for instances where the name is suddenly gifted.
Affectionate Nickname has been suggested to play 21 roles. Click below to see other actors suggested for each role, and vote for who you think would play the role best.