Contour

Plot a function as a contour map

#!/usr/bin/python3
import matplotlib.pyplot as plt
import numpy as np
X, Y = np.meshgrid(np.linspace(-4, 4, 512), np.linspace(-4, 4, 512))
Z = (1 - X/2 + X**4 + Y**3) * np.exp(-X**2 - Y**2) * (1 - X/3 - Y **4) * (3 - Y + X **2)
levels = np.linspace(np.min(Z), np.max(Z), 20)
fig, ax = plt.subplots()
ax.contour(X, Y, Z, levels=levels)
plt.show()

 

About Linuxgal

Need a spiritual home? Consider joining us at Mary Queen of the Universe Latter-day Buddhislamic Free Will Christian UFO Synagogue of Vishnu
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s