Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from mpl_toolkits import mplot3d
- import numpy as np
- import matplotlib.pyplot as plt
- #create 3d axes
- fig = plt.figure()
- ax = plt.axes(projection='3d')
- #function for Z values
- def f(x, y):
- c = [2, 3, 8, 3, 2, 8]
- a = [3, -5, 0, 3, -4, 6]
- b = [-4, -6, -1, 7, 0, 5]
- sum = 0
- for i in range(6):
- sum += c[i] / (1 + (x - a[i]) ** 2 + (y - b[i]) ** 2)
- return sum
- # x and y values
- x = np.linspace(-10, 10, 100)
- y = np.linspace(-10, 10, 100)
- X, Y = np.meshgrid(x, y)
- Z = f(X, Y)
- ax = plt.axes(projection ='3d')
- ax.plot_surface(X, Y, Z, rstride=1, cstride=1,
- cmap='viridis')
- ax.view_init(0, 90)
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement