Visualizing more than one parameter

We have already seen that we can use Matplotlib to create a beautiful diagram. Here, we would like to introduce how we can use mplot3d to visualize more than three parameters. Let's say we want to see how the number of floors and the number of bedrooms are related to the bathroom. The first step is to import the library:

from mpl_toolkits.mplot3d import Axes3D

Then let's add the required parameters: 

fig=plt.figure(figsize=(19,12.5))
ax=fig.add_subplot(2,2,1, projection="3d")
ax.scatter(data['floors'],data['bedrooms'],data['bathrooms'],c="darkgreen",alpha=.5)
ax.set(xlabel=' Floors',ylabel=' Bedrooms',zlabel=' Bathrooms / Bedrooms')
ax.set(ylim=[0,12])

The snippet should give a 3D chart, as follows:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.21.248.47