import matplotlib.pyplot as plt
import numpy as np
from astropy.visualization import simple_norm
from photutils.datasets import make_100gaussians_image
from scipy.ndimage import rotate

data = make_100gaussians_image()
ny, nx = data.shape
y, x = np.mgrid[:ny, :nx]
gradient = x * y / 5000.0
data2 = data + gradient
data3 = rotate(data2, -45.0)
norm = simple_norm(data3, 'sqrt', percent=99.5)
fig, ax = plt.subplots()
ax.imshow(data3, norm=norm, origin='lower')
ax.set_title('Data with added background gradient')