How to save a plot as a jpeg file?

Linking this post by @joa-quim.