December 2017
Intermediate to advanced
386 pages
10h 42m
English
We start by importing the Axes3D class from the mpl_toolkits.mplot3d library, which is the Matplotlib object used for creating three-dimensional plots. We also import the cm class, which represents a color map. We then define a function to be plotted, with the following line of code:
f = lambda x,y: x**3 - 3*x*y**2
The next step is to define the Figure object and an Axes object with a 3D projection, as done in the following lines of code:
fig = plt.figure(figsize=(12,6))ax = fig.add_subplot(1,2,1,projection='3d')
Notice that the approach used here is somewhat different than the other recipes in this chapter. We are assigning the output of the figure() function call to the fig variable and then adding the subplot by calling the ...
Read now
Unlock full access