The chemical reactions and pathways involving anthocyanins, any member of a group of intensely colored soluble glycosides of anthocyanidins that occur in plants. They are responsible from most of the scarlet, purple, mauve and blue coloring in higher plants, especially of flowers.