Making Interactive Matplotlib Plots for Data Science Visualizations on Jupyter (Python)

1littlecoder · Beginner ·🛠️ AI Tools & Apps ·6y ago
This tutorial introduces you the python package `ipympl` (jupyter-matplotlib) for making interactive matplotlib python data science visualization. Please note, this doesn't make the entire plot interactive rather puts an interactive widget of matplotlib with features like Pan and Zoom

What You'll Learn

Makes interactive Matplotlib plots for data science visualizations on Jupyter using ipympl

Full Transcript

in this tutorial we are going to see how to make a typical matplotlib interactive so there are a lot of options in Python for interactive plot like bouquet alter plot Lee but in this tutorial we are going to see how to use your existing matplotlib and then make it interactive on a jupiter notebook of jupiter lab so the same thing that we are doing in this tutorial could be also applied for jupiter lab but i'm going to demonstrate it using just jupiter notebook so assuming that you have got jupiter notebook opened you have to first install i pi widgets which is what you are going to use internally to create widget and the package that we are going to use in this tutorial is i pi MPL so it is actually jupiter matplotlib so the package name is i pi m PL but the name of the package you can see that it's a it's a Jupiter nut plot lib and yeah we would like to thank the developers of this package for their open source contribution which we are going to use in this case so two packages make sure that you have installed both the libraries and if you do not have admin rights just use - - you system I would just show you since I have already installed then it's going to say that the requirement is already installed satisfied but if you do not have just installed the package once you install these two packages now you have to run these things in your terminal or shell or command prompt or wherever you have so first you have to enable the widgets then you have to enable this extension so once you have these two things set up now you are ready to go ahead and then start your matplotlib so your typical matplotlib would look like this so this is an example from documentation so when you're under sting so this is where your plot looks and for you to get this plot you are going to say matplotlib in line but in this case because you want it as a widget what you can do is matplotlib widget so once you do this thing and when you run this thing you're going to see your matplotlib entire matplotlib appearing inside a widget so this is the widget that we installed the first I private jet so now it is appearing us and Bridget so the advantage of which it is that you can resize it you can do like this you can extend it you can do whatever you want with that and once you do that thing so the other option that you get this you can pan and zoom it so let's say now I've got it like this now I can pan it so I'm going to extend it and then I'm going to select a pan I can pan it so I can pan it or let's say I want to zoom it for a particular time period maybe I'm making a presentation for the executive team maybe I'm making a presentation for the business team and I want to just focus on this particular point so now I can select zoom tool and then I can zoom it okay so I can just so much so this is all I can zoom it so if I don't want anything to happen just I can just click home so the entire thing would get reset to the original view so I think there's something there is a delay in my home but yeah so when once you click home it's going to reset the position to the older one so yeah so that is that is for a normal 2d plot um so you just take a static plot and then you embed it in a widget that wins widget makes it easier for you to make this plot interactive but now what to do with the 3d plot show me the 3d plot is not quite common in the industry but let's say you have a 3d plot you can still use the same matplotlib jupiter widget to show a 3d plot and the plot is getting slight delay to get generated so once you have this thing a 3d plot now you can rotate it actually you can rotate it in three dimension so so as you can see I've just rotated the plot so you can rotate the plot and you can do the same thing like panning and zooming anything that you want you can do it with that so that main advantage with this interactive matplotlib package is that you don't have to really learn a new syntax something like plotly or bouquet or altar to create interactive plots in a lot of cases you are going to share this notebook with someone else so you do not want true interactivity what do I mean by that is you don't want all the data points in your plot to be interactive you don't want some when you hover it or something to show the data point all you want us the ability to pan and zoom or show a particular data point within the plot and that is quite possible with this package itself which means you can simply use your existing matplotlib code and as usual where you use matplotlib in line for a jupiter notebook that is this is how it would be if it is in line you just have to change that plot live widget so your dependencies become very less and your existing plot actually becomes a widget and then you get this interactive capability which is quite awesome given that you don't have to now learn a new syntax arrium you know you have the ability to share it with your team members and then you can save this notebook and then you can share it with others so so that's that's quite an interesting package and the same thing is applicable for jupiter lab also but i've just demonstrated a jupiter notebook so if you want this thing start with this package and as a good practice when you find something in interesting online as an open source project please start the airpo that is that is a way of you you know thanking them so star they rapport go through the instructions in here just um you can see that their demonstration is on jupiter lab install the package you have multiple ways to install the package so you if you are using anaconda you can do a Conda install if you want to just do a pip install just like how I did it you can do it with people install and if you want to use the development version you can develop use the development version from github and in case if you are facing some issue make sure that you have your node.js installed you can download node.js just from internet you are using Mac or Windows you can download the node.js version so even after you have no J you have you have no GS and then you have done the the ones that we just did let's say you have enable the extension after even after that if you have some issue please go to the packages from github repo and then raise it as an issue with the appropriate term details about what is the issue that you are facing but I I think it should be quite straightforward for you to set it up up and running so let us hope that you can get it up and running and please let me know in the comments that if you face any difficulties I'd try to help you thank you for watching see you in the next video
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from 1littlecoder · 1littlecoder · 2 of 60

1 How to create your Free Data Science Blog on Github with Fastpages from Fastai
How to create your Free Data Science Blog on Github with Fastpages from Fastai
1littlecoder
Making Interactive Matplotlib Plots for Data Science Visualizations on Jupyter (Python)
Making Interactive Matplotlib Plots for Data Science Visualizations on Jupyter (Python)
1littlecoder
3 Create your first Data Science Web App using R Shiny
Create your first Data Science Web App using R Shiny
1littlecoder
4 How to create a Reproducible Example in R using reprex
How to create a Reproducible Example in R using reprex
1littlecoder
5 No Code Visualization using esquisse with Tableau-like Drag and Drop GUI in R
No Code Visualization using esquisse with Tableau-like Drag and Drop GUI in R
1littlecoder
6 Scrape HTML Table using rvest and Process them for insights using tidyverse in R
Scrape HTML Table using rvest and Process them for insights using tidyverse in R
1littlecoder
7 Google Teachable Machine Learning Build No Code AI solution
Google Teachable Machine Learning Build No Code AI solution
1littlecoder
8 Create meaningful fake tidy datasets in R using fakir [#rstats Package]
Create meaningful fake tidy datasets in R using fakir [#rstats Package]
1littlecoder
9 How to enable using R Programming with Visual Studio VS Code
How to enable using R Programming with Visual Studio VS Code
1littlecoder
10 Python, Community, Books - with Abhiram R - Bangpypers Co-organizers | 1littlecoder podcast
Python, Community, Books - with Abhiram R - Bangpypers Co-organizers | 1littlecoder podcast
1littlecoder
11 Growing a Tech Community across India - Anubha Maneshwar, Founder Girlscript | 1littlecoder Podcast
Growing a Tech Community across India - Anubha Maneshwar, Founder Girlscript | 1littlecoder Podcast
1littlecoder
12 Intro to Google Colab - How to use Colab
Intro to Google Colab - How to use Colab
1littlecoder
13 Intro to Plotly Express - Complex Interactive Charts with One-Line of Python Code
Intro to Plotly Express - Complex Interactive Charts with One-Line of Python Code
1littlecoder
14 Indic NLP Python Toolkit Open Source Development - iNLTK Creator Gaurav Arora | 1littlecoder Podcast
Indic NLP Python Toolkit Open Source Development - iNLTK Creator Gaurav Arora | 1littlecoder Podcast
1littlecoder
15 Do you want a career in Data Science - Tamil Webinar
Do you want a career in Data Science - Tamil Webinar
1littlecoder
16 Android Smartphone Analysis in R [Live Coding Screencast]
Android Smartphone Analysis in R [Live Coding Screencast]
1littlecoder
17 Programmatically create Images, Memes, Watermarks using Python with imgmaker
Programmatically create Images, Memes, Watermarks using Python with imgmaker
1littlecoder
18 Kaggle Walkthrough to get you started with Data Science - Webinar
Kaggle Walkthrough to get you started with Data Science - Webinar
1littlecoder
19 Community, Corporate Job, Coding - Gnana Lakshmi T C aka Gyan, WomenWhoCode Leadership Fellow
Community, Corporate Job, Coding - Gnana Lakshmi T C aka Gyan, WomenWhoCode Leadership Fellow
1littlecoder
20 Easy ggplot2 Theme Customization with {ggeasy} | Data Visualization in R
Easy ggplot2 Theme Customization with {ggeasy} | Data Visualization in R
1littlecoder
21 Excel to R - Pivot + Bar Chart in Excel  & R using tidyverse [Live Coding]
Excel to R - Pivot + Bar Chart in Excel & R using tidyverse [Live Coding]
1littlecoder
22 Excel to R #2 - VLOOKUP in Excel to LEFT_JOIN, MERGE in R
Excel to R #2 - VLOOKUP in Excel to LEFT_JOIN, MERGE in R
1littlecoder
23 5 websites to get Free Real-World Datasets for Data Science/ML Projects
5 websites to get Free Real-World Datasets for Data Science/ML Projects
1littlecoder
24 Excel to R #3 - APPROXIMATE VLOOKUP in Excel to FUZZY LEFT_JOIN in R
Excel to R #3 - APPROXIMATE VLOOKUP in Excel to FUZZY LEFT_JOIN in R
1littlecoder
25 Correlation-alternative PPS (Predictive Power Score) Python Package Demo
Correlation-alternative PPS (Predictive Power Score) Python Package Demo
1littlecoder
26 Automated Website Screenshots in R using {webshot}
Automated Website Screenshots in R using {webshot}
1littlecoder
27 Installing Custom RStudio Theme (Synthwave85)
Installing Custom RStudio Theme (Synthwave85)
1littlecoder
28 Analyse Google Trends Search Data in R using {gtrendsR}
Analyse Google Trends Search Data in R using {gtrendsR}
1littlecoder
29 3 Tips to ask question on Stack Overflow the right way to get answers
3 Tips to ask question on Stack Overflow the right way to get answers
1littlecoder
30 Learn Data Science with R - Mini Projects - Web Scraping Zomato
Learn Data Science with R - Mini Projects - Web Scraping Zomato
1littlecoder
31 Easily make Dumbbell Chart using {ggcharts} | Data Visualization in R
Easily make Dumbbell Chart using {ggcharts} | Data Visualization in R
1littlecoder
32 GET Hackernews Front Page Results using REST API in R
GET Hackernews Front Page Results using REST API in R
1littlecoder
33 Quickly deploy ML WebApps from Google Colab using ngrok
Quickly deploy ML WebApps from Google Colab using ngrok
1littlecoder
34 Use Jupyter Notebooks within VSCode (Visual Studio Code) in 2020
Use Jupyter Notebooks within VSCode (Visual Studio Code) in 2020
1littlecoder
35 Plotly Interactive Plots as Pandas Plotting Backend df.plot()
Plotly Interactive Plots as Pandas Plotting Backend df.plot()
1littlecoder
36 Stack Overflow Developer Survey 2020 Highlights for New Programmers
Stack Overflow Developer Survey 2020 Highlights for New Programmers
1littlecoder
37 Matplotlib Animation Charts in Python using Celluloid
Matplotlib Animation Charts in Python using Celluloid
1littlecoder
38 Coding, Postwoman, Passion Project Book - Liyas Thomas Open Source Developer - 1littlecoder podcast
Coding, Postwoman, Passion Project Book - Liyas Thomas Open Source Developer - 1littlecoder podcast
1littlecoder
39 Aspiring Data Scientist, Tips on How to learn Business Domain Knowledge
Aspiring Data Scientist, Tips on How to learn Business Domain Knowledge
1littlecoder
40 Bokeh Interactive Charts as Pandas Plotting Backend df.plot_bokeh()
Bokeh Interactive Charts as Pandas Plotting Backend df.plot_bokeh()
1littlecoder
41 Easy Fast Python Pandas Summary with Sidetable | Pandas Tips & Tricks
Easy Fast Python Pandas Summary with Sidetable | Pandas Tips & Tricks
1littlecoder
42 Inception, Content Ideas, Consistency - Srivatsan Srinivasan AIEngineering YouTube Content Creator
Inception, Content Ideas, Consistency - Srivatsan Srinivasan AIEngineering YouTube Content Creator
1littlecoder
43 ggplot2 Text Customization with ggtext | Data Visualization in R
ggplot2 Text Customization with ggtext | Data Visualization in R
1littlecoder
44 Penguins Dataset Overview - iris alternative | EDA Data Visualization in R
Penguins Dataset Overview - iris alternative | EDA Data Visualization in R
1littlecoder
45 YouTube Growth Tips, Content Creation - Bhavesh Bhatt, YouTuber (Data Science & Machine Learning) #7
YouTube Growth Tips, Content Creation - Bhavesh Bhatt, YouTuber (Data Science & Machine Learning) #7
1littlecoder
46 Matplotlib Animated Bar Chart Race in Python | Data Visualization
Matplotlib Animated Bar Chart Race in Python | Data Visualization
1littlecoder
47 Simple Python GUI Development using {guietta}
Simple Python GUI Development using {guietta}
1littlecoder
48 #8 Niche, Growth, Monetization - David Langer - YouTuber Dave on Data
#8 Niche, Growth, Monetization - David Langer - YouTuber Dave on Data
1littlecoder
49 Simple Fast 3-step Python OCR using Deep Learning 40+ Languages
Simple Fast 3-step Python OCR using Deep Learning 40+ Languages
1littlecoder
50 Github New Feature Profile Summary/Mini-Resume - Profile Views
Github New Feature Profile Summary/Mini-Resume - Profile Views
1littlecoder
51 Otto ML Assistant, GPT-3 on Philosophers, Nvidia-ARM - 3 ML Tech News
Otto ML Assistant, GPT-3 on Philosophers, Nvidia-ARM - 3 ML Tech News
1littlecoder
52 What is OpenAI GPT-3 - Hype, Examples, Worries
What is OpenAI GPT-3 - Hype, Examples, Worries
1littlecoder
53 Julia 1.5, Datamuse API, Live HDR+ Pixel 4a - Machine Learning Tech News
Julia 1.5, Datamuse API, Live HDR+ Pixel 4a - Machine Learning Tech News
1littlecoder
54 Self-driving Car Engineer sentenced, arXiv Dataset, AI/ML Startup Idea - Machine Learning Tech News
Self-driving Car Engineer sentenced, arXiv Dataset, AI/ML Startup Idea - Machine Learning Tech News
1littlecoder
55 GPT-3 Explorer, Ciphey (Automated Decryption), Py-Sudoku - ML Tech News
GPT-3 Explorer, Ciphey (Automated Decryption), Py-Sudoku - ML Tech News
1littlecoder
56 How to use Advanced Google Search to extract Email Ids from Linkedin
How to use Advanced Google Search to extract Email Ids from Linkedin
1littlecoder
57 Cartoonizer Toon-IT (AI Web App), GPT-3 Advice, Android Earthquake Detection - ML Tech News
Cartoonizer Toon-IT (AI Web App), GPT-3 Advice, Android Earthquake Detection - ML Tech News
1littlecoder
58 Flow - R Package to visualize code logic, functions as a Flow Diagram
Flow - R Package to visualize code logic, functions as a Flow Diagram
1littlecoder
59 Build GPT-3-like Language Model on Google Colab with minGPT [PyTorch]
Build GPT-3-like Language Model on Google Colab with minGPT [PyTorch]
1littlecoder
60 Create a Pencil Sketch Portrait with Python OpenCV
Create a Pencil Sketch Portrait with Python OpenCV
1littlecoder

Related AI Lessons

Up next
I Asked ChatGPT to Apply to 500 Jobs (8 Interviews in 48 Hours)
Sabrina Ramonov 🍄
Watch →