![]() |
Matplotlib is a data visualization library. It is difficult to analyze/get an insight into the data without visualizing it. And matplotlib is a great library for doing the visual analysis of data in python. Using matplotlib we can plot 1-D, 2-D and even 3-D data. In this article, we are going to learn how we can plot various 3-D plots using the matplotlib. To plot 3-D plots in python, we need to import the mplot3d library from the standard installation of matplotlib library from python. As matplotlib is a third-party library, it doesn’t come with a standard installation of python, so you need to install matplotlib before following this article. Below is the command using which you can install the matplotlib library. Syntax:
To make the plots interactive all you need to do is install another library called ipympl i.e. interactive python matplotlib. Syntax:
For creating 3d figure Axes3D.plot() function is used.
To generate an interactive 3D plot first import the necessary packages and create a random dataset. Now using Axes3D(figure) function from the mplot3d library we can generate a required plot directly. Pass the data to the 3D plot and configure the title and labels. Note: We must needed to add ” %matplotlib widget “, it is a Jupyter magic widget and used to tell jupyter to use interactive backend for plot. We have to add it to the top of the script to create an interactive plot in the ipython notebook (i.e. Jupyter notebook, Google Colab, Kaggle Kernel, etc.) to render the figure as an interactive figure. Given below are some implementations to do the same. Example: Interactive scatter plot Python3
Output: ![]() Interactive 3D plot in Jupyter notebook Example: Interactive bar plot Python
Output: ![]() Interactive 3D plot |
Reffered: https://www.geeksforgeeks.org
Python |
Related |
---|
![]() |
![]() |
![]() |
![]() |
![]() |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 8 |