Skip to content

Instantly share code, notes, and snippets.

@takeouchida
Created August 1, 2022 14:30
Show Gist options
  • Save takeouchida/205fe988477d183926ac9a9616157df0 to your computer and use it in GitHub Desktop.
Save takeouchida/205fe988477d183926ac9a9616157df0 to your computer and use it in GitHub Desktop.
Plot f(x, y) = x^2 + y^2 + x^2*y + 4 in Python
import matplotlib.pyplot as plt
from matplotlib import cm
from matplotlib.ticker import LinearLocator
import numpy as np
fig, ax = plt.subplots(subplot_kw={"projection": "3d"})
x = np.arange(-5, 5, 0.25)
y = np.arange(-5, 5, 0.25)
x, y = np.meshgrid(x, y)
z = x * x + y * y + x * x * y + 4
surf = ax.plot_surface(x, y, z, cmap=cm.coolwarm, linewidth=0, antialiased=False)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment