Skip to content

Instantly share code, notes, and snippets.

@Wouterr0
Created March 13, 2022 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Wouterr0/dff501838cc32fbcd85af3f327ae0c5d to your computer and use it in GitHub Desktop.
Save Wouterr0/dff501838cc32fbcd85af3f327ae0c5d to your computer and use it in GitHub Desktop.
import matplotlib.pyplot as plt
import numpy as np
min = -5
max = 5
step = .1
width = (max-min)/step
fx0 = lambda x, y: abs(x) + abs(y)
fx1 = lambda x, y: x**2 + y**2
fx2 = lambda x, y: abs(x**3) + abs(y**3)
fxs = [
lambda x, y: abs(x) + abs(y),
lambda x, y: x**2 + y**2,
lambda x, y: abs(x**3) + abs(y**3),
lambda x, y: x**20 + y**20,
]
for fx in fxs:
x,y = np.mgrid[min:max:((max-min)/step)*1j, min:max:((max-min)/step)*1j]
z = fx(x,y)
extent = [min, max, min, max]
plt.imshow(z, extent=extent)
plt.colorbar()
plt.contour(z, levels=[1.0], colors=["black"], extent=extent)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment