import numpy as np
from scipy.stats import multivariate_normal as mvn

def mog2(x):
    L  = np.array([[1., 0], [1., 2.]])
    return mvn(mean=np.array([-2., 2.]),
               cov=np.matmul(L, L.T)).pdf(x) + \
           mvn(mean=np.array([2., -2.])).pdf(x)

## Density for a Mixture of Two Gaussians.
x = np.mgrid[-5:5:.1, -5:6.5:.1]
pdf = mog2(x.reshape(2, -1).T).reshape(*x.shape[1:])

import matplotlib.pyplot as plt
import seaborn as sns

sns.set(font_scale=2., style='whitegrid')

Contour Lines Plot

fig, ax = plt.subplots(figsize=(7,7))

ax.contour(x[0], x[1], pdf, levels=10,
            cmap=sns.color_palette("magma", as_cmap=True))
ax.set_axis_off()
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> 2021-08-17T21:51:50.624555 image/svg+xml Matplotlib v3.4.2, https://matplotlib.org/

Filled Contour Plot

fig, ax = plt.subplots(figsize=(7,7))

ax.contourf(x[0], x[1], pdf, levels=7,
            cmap=sns.color_palette("crest_r", as_cmap=True))
ax.set_axis_off()
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> 2021-08-17T21:51:51.126583 image/svg+xml Matplotlib v3.4.2, https://matplotlib.org/

Contour Plots with colorbar

fig, ax = plt.subplots(figsize=(7,7))

cf = ax.contourf(x[0], x[1], pdf, levels=7,
                      cmap=sns.color_palette("crest_r", as_cmap=True))
ax.set_xticks([])
ax.set_yticks([])
ax.set_xlabel('x')
ax.set_ylabel('y')

cbaxes = fig.add_axes([.2, .02, .6, .02]) 
fig.colorbar(cf, ticks=np.linspace(0., .2, 6),
             orientation='horizontal', cax=cbaxes);
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> 2021-08-17T21:51:51.658109 image/svg+xml Matplotlib v3.4.2, https://matplotlib.org/