In Shakespeare's Macbeth, Act III, scene iv, metonymy is used in line 18.
"Metonymy" is a complicated literary device when one first looks at it; but once you can wrap your brain around it, it is easier to see the flexibility and artistry evident in language. Metonymy comes from...
...the Greek [meaning] "changed label"; the name of one object is substituted for that of another closely associated with it...
One of my favorite examples comes from "The Love Song of J. Alfred Prufrock," written by T.S. Eliot:
I should have been a pair of ragged claws
Scuttling across the floors of silent seas. (lines 73-74)
In this example, the speaker notes not that he should be a crab on the sea floor, but "a pair of ragged claws." The claws represent the crab. Why not simply say "crab?" This comes from a poem. Many of the most stunning uses of literary devices are found in poetry because of the freer, more poetic nature of the writing. It creates music for one's ears using words. Literary devices offer insight to much of the most impressive thoughts and expressions of poetic genius. In other words, it sounds better. (And remember, Shakespeare writes poetically in his sonnets and plays!)
You use this device when you speak of eating cookies or brownies. You might say, "I could eat the whole plate." You don't mean to eat the plate, but what is on the plate. This makes the writing figurative rather than literal, which is what literary devices are: creating resplendent images in the mind as we read.
Not a literary device that gets a great deal of attention—like metaphors and similes—metonymy is a wonderful writing tool. Look then, to the quote in Macbeth. The tyrant king has just ordered the murder of his best friend, Banquo. One of the murderers comes to say that part of Macbeth's plan has been carried out: Banquo is dead.
Thou art the best o’ the cut-throats! (18)
"Cut-throat" represents what the murderer does, but he is a murderer, an assassin. This expression has come to mean the same thing, but the association of the method of murder now represents the label of the person who does the deed.
A more traditional literary device is found in lines 32-34, with the famous extended metaphor that describes Banquo and his son Fleance (and recall that Fleance gets away).
There the grown serpent lies; the worm that's fled
Hath nature that in time will venom breed,
No teeth for the present.
In this case, remember that a metaphor is the comparison of two dissimilar things that share similar characteristics, and they are presented as if they were the same thing.
Here Macbeth says that Banquo is "a grown serpent." This is figurative, of course. Banquo is not a snake, but had (as Macbeth sees it) similar characteristics. Banquo was dangerous to Macbeth's plan to hold on to the throne. He knew of the witches' predictions and could have questioned how Macbeth became King...did he help Duncan into his grave because the witches prophesied that he would be King? Macbeth kills him because he knows Banquo is honest and would not remain silent.
Using the same comparison ("extending" the metaphor), Macbeth worries because Fleance has escaped. He calls him a "worm," like a baby snake, with "no teeth for the present" (not a danger now), but could be so later—"in time will venom breed." Neither father nor son is a snake of any kind, but Macbeth sees in them danger to his rule as King of Scotland.
Scene 4 of Act III takes place at Macbeth's palace where a banquet has been prepared with Macbeth, Lady Macbeth, Ross, Lennox, Lords, and attendants present. As the banquet begins, Macbeth is informed by one of the murderers of Banquo that Fleance has escaped. Although Macbeth dismisses the man, he is visibly shaken; in fact, he later imagines that he sees the ghost of Banquo. In Scene 4, the phantasmorgic realm dominates Macbeth and he is visibly shaken.
At the point in which the murderer informs Macbeth that Fleance has escaped, Macbeth employs similes in his remarks,
Then comes my fit again: I had else been perfect,
Whole as the marble, founded as the rock,
As broad and general as the casing air: (3.4.23-25)
Similes are stated comparisons between two unlike things using the words like or as. In the above passage, Macbeth compares his nature with "marble," "rock," and "casing air." But, when he encounters Banquo's ghost, Macbeth's fortitude leaves him.