Density gradient effects on the magnetorotational instability