Many blue or purple flowers contain pigments known as anthocyanins. These compounds change color depending on the pH of the solution they are in. Here's a simple demonstration with some wild violets from my yard.
You might also like