Global magnetic patterns in the Milky Way and the Andromeda nebula