Skip to content

Instantly share code, notes, and snippets.

@AlexTitovWork
Last active March 6, 2024 09:12
Show Gist options
  • Save AlexTitovWork/d66584382619e5edba151867e41cba3e to your computer and use it in GitHub Desktop.
Save AlexTitovWork/d66584382619e5edba151867e41cba3e to your computer and use it in GitHub Desktop.
Plotting the Himmelblau function
import numpy as np
import matplotlib.pyplot as plt
# ################################################################################
def plot_function():
# Make data.
X = np.arange(-5, 5, 0.25)
Y = np.arange(-5, 5, 0.25)
X, Y = np.meshgrid(X, Y)
Z = (X ** 2 + Y - 11) ** 2 + (X + Y ** 2 - 7) ** 2
# Plot the surface.
fig = plt.figure()
ax = fig.gca(projection='3d')
surf = ax.plot_surface(X, Y, Z, cmap=cm.coolwarm,
linewidth=0, antialiased=False)
ax.set_xlabel('X Label')
ax.set_ylabel('Y Label')
ax.set_zlabel('Z Label')
return X, Y, Z
# ################################################################################
X, Y, Z = plot_function()
@AlexTitovWork
Copy link
Author

изображение

@floffy-f
Copy link

floffy-f commented Mar 6, 2024

Perfect ! Thank you for your response and cool code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment