Atmospheric density is very much affected by gravity. I'm not sure magnetic field has any appreciable effect at all on the density of the earth's atmosphere. Why would it? The vast majority of the atmosphere isn't charged, so doesn't interact directly with magnetism.