#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Nov 25 17:48:06 2020 @author: bethandonovan """ # This import registers the 3D projection, but is otherwise unused. from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import import matplotlib.pyplot as plt from matplotlib import cm from matplotlib.ticker import LinearLocator, FormatStrFormatter import numpy as np fig = plt.figure() ax = fig.gca(projection='3d') # Make data. X = np.arange(-80, 80, 10) Y = np.arange(-80, 80, 10) x, y = np.meshgrid(X, Y) Z_X = [9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9] Z_Y = [9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9] Z = np.empty([17,17]) for n1 in range(17): for n2 in range(17): Zz = np.sqrt(Z_X[n1]**2+Z_Y[n2]**2) Z[n1,n2]= Zz # Plot the surface. #surf = ax.plot_surface(x, y, Z, cmap=cm.coolwarm, # linewidth=0, antialiased=False) # Customize the z axis. ax.set_zlim(-1.01, 1.01) ax.zaxis.set_major_locator(LinearLocator(10)) ax.zaxis.set_major_formatter(FormatStrFormatter('%.02f')) # Add a color bar which maps values to colors. fig.colorbar(surf, shrink=0.5, aspect=5) plt.show()