3D Plotting in Matplotlib for Python: 3D Scatter Plot

sentdex · Beginner ·🛠️ AI Tools & Apps ·13y ago

Key Takeaways

Plots 3D scatter plots in Matplotlib for Python to compare data sets

Full Transcript

Hello everybody welcome back to the matplot lib 3D graph Series in this tutorial video we're going to be talking about putting up uh three-dimensional Scatter Plots and then also adding uh labels to our plot color and plot um look or feel or whatever you want to call it um with the first video in the 3D series I just kind of wanted to keep it as basic as possible and then as time goes on we'll continue adding layers not only to the you know cuz basically we're going over different chart types and then now we're going to start adding stuff that is kind of similar AC like you're going to have labels all across and then the colors and the line type and all this kind of stuff um kind of follows you no matter what you're doing in the 3D plotting so that's kind of what I'd like to do with this 3D Series so anyway with that let's hop right in um same thing as before we're going to need from npl toolkit. mplot3d import axis 3D and then the next thing we're going to need is import matplot li. plot as PLT done next thing we want to do fig uh equals plot figure nothing new nothing new AIS equals fig. addore subplot nothing new same thing as before and then projection equals 3D same thing as before there as well now we're going to toss it up a little bit the last time we what we did was XYZ equals and then three arrays instead what I'd like to do if since we're having kind of long arrays I think that it's better to do x equals an array y equals an array and Z equals an array since our data is so long but I would you know probably in the at the end of the day you're going to end up uh finally doing like an XY Z and equals that numpy array that we had done in the map plot lib series prior to these videos so um with that this is just another way to think about doing it if you do have a lot of data but chances are if you have a lot of data you're probably um pulling from a file or something like you're not hand typing it in but anyway we're just I'm just going to show you you know there's multiple ways to do the same thing in programming and so it's just good to show the multiple ways to do it so anyway we're just going to make up some data again if you still have your data from before you can start arranging it this way or you can leave it the way you had it it doesn't really matter um I think it was something like that okay so now we have what I believe to be 10 of each hopefully the next thing we want and this will be a little different it's going to be ax. scatter for scatter plot and then then we're going to do XY Z to plot the next thing we have is c for color and we're going to say the color is going to be red and then now we have marker in this there's all kinds of different markers and in this case we're going to use the uh just a zero for like a circular marker and finally um you can also set labels so we're going to go ahead and do that so ax. set uncore and X label and we're just going to call this um x axis and then the same thing for the other ones let's just copy and paste this save some time so this will be x y and z z y and x so now the next thing obviously Plot show plot shop go shopping save we'll run this hopefully no errors of course we had errors ah we need to capitalize the D it's axis 3 capital D for Dimensions let's try again all right here we go and we have our plot let me fit it to screen now you can see that instead of like lines they're you know Scatter Plots on the chart and they're red and circles and beautiful we also have our x axis our y axis and our z-axis uh labeled here for us and the other thing you'll note that I think is pretty impressive again that took quite a bit of uh coding is is this visually it's very hard for you to tell which plot is closer this one or this one now if they were the exact same red that is but visually you know because this one's obviously closer as you can see as you turn it you can see it visually but also when it's a static chart say you only took an image of it you'd also know because this is kind of faded a little bit so it gives you the um the really it's an illusion that this plot is further back so as we rotate you know you do see that it it was further back it's still further back and then as it comes closer it's it's clear that okay now it's really close so anyway um just little subtle things like that uh just definitely impressed me I think that's really awesome for this uh graphing it's so it's just such a simple little graphing program and it's really lightweight so it's just a great great program anyway um that's basically it as far as making uh um threedimensional Scatter Plots as always thanks for watching stay tuned to the next video and thanks for your support your subscriptions

Original Description

Besides 3D wires, and planes, one of the most popular 3-dimensional graph types is 3D scatter plots. The idea of 3D scatter plots is that you can compare 3 characteristics of a data set instead of two. Sample code: http://pythonprogramming.net/matplotlib-3d-scatterplot-tutorial/ Link to the full playlist: http://www.youtube.com/playlist?list=PLQVvvaa0QuDfpEcGUM6ogsbrlWtqpS5-1 Sentdex.com Facebook.com/sentdex Twitter.com/sentdex How to generate interactive 3d scatterplots in Matplotlib and Python
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from sentdex · sentdex · 47 of 60

1 Matplotlib Python Tutorial Part 1: Basics and your first Graph!
Matplotlib Python Tutorial Part 1: Basics and your first Graph!
sentdex
2 Python Encryption Tutorial with PyCrypto
Python Encryption Tutorial with PyCrypto
sentdex
3 Python's Logging Function
Python's Logging Function
sentdex
4 wxPython Tutorials 1: Making Windows GUIs with Python : Installing + 1st window!
wxPython Tutorials 1: Making Windows GUIs with Python : Installing + 1st window!
sentdex
5 wxPython Tutorials 2: Making Windows GUIs with Python: Customizing Window Parameters
wxPython Tutorials 2: Making Windows GUIs with Python: Customizing Window Parameters
sentdex
6 wxPython Programming Tutorial 3: Menu Bar and Menu Button
wxPython Programming Tutorial 3: Menu Bar and Menu Button
sentdex
7 wxPython Programming Tutorial 4: Panels
wxPython Programming Tutorial 4: Panels
sentdex
8 wxPython Programming Tutorial 5: User Input Saved To Variables
wxPython Programming Tutorial 5: User Input Saved To Variables
sentdex
9 wxPython Programming Tutorial 6: Multiple Choice Input
wxPython Programming Tutorial 6: Multiple Choice Input
sentdex
10 wxPython Programming Tutorial 7: Adding Static Text and Colors
wxPython Programming Tutorial 7: Adding Static Text and Colors
sentdex
11 wxPython Programming Tutorial 8: Custom Button Images
wxPython Programming Tutorial 8: Custom Button Images
sentdex
12 wxPython Programming Tutorial 9: Tool Bar Items and Sub Menus!
wxPython Programming Tutorial 9: Tool Bar Items and Sub Menus!
sentdex
13 Basic PHP Tutorial 13: Multi-dimensional Array
Basic PHP Tutorial 13: Multi-dimensional Array
sentdex
14 Basic PHP Tutorial 15: Functions and Global Variables
Basic PHP Tutorial 15: Functions and Global Variables
sentdex
15 Basic PHP Tutorial 12: Associative Array
Basic PHP Tutorial 12: Associative Array
sentdex
16 Basic PHP Tutorial 14: Foreach loop
Basic PHP Tutorial 14: Foreach loop
sentdex
17 Basic PHP Tutorial 16: Include and Require
Basic PHP Tutorial 16: Include and Require
sentdex
18 Basic PHP Tutorial 7: Assignment, comparison and Logical operators
Basic PHP Tutorial 7: Assignment, comparison and Logical operators
sentdex
19 Basic PHP Tutorial 4: Variables and Comments
Basic PHP Tutorial 4: Variables and Comments
sentdex
20 Basic PHP Tutorial 11: Arrays part 1, basic array
Basic PHP Tutorial 11: Arrays part 1, basic array
sentdex
21 Basic PHP Tutorial 6: If else and else if conditionals cont'd
Basic PHP Tutorial 6: If else and else if conditionals cont'd
sentdex
22 Basic PHP Tutorial 1: Intro to PHP
Basic PHP Tutorial 1: Intro to PHP
sentdex
23 Basic PHP Tutorial 3: HTML with PHP
Basic PHP Tutorial 3: HTML with PHP
sentdex
24 Basic PHP Tutorial 9: While Loop
Basic PHP Tutorial 9: While Loop
sentdex
25 Basic PHP Tutorial 10: Switch Statement
Basic PHP Tutorial 10: Switch Statement
sentdex
26 Basic PHP Tutorial 2: Print and Echo
Basic PHP Tutorial 2: Print and Echo
sentdex
27 Basic PHP Tutorial 5: If else and else if conditional statements
Basic PHP Tutorial 5: If else and else if conditional statements
sentdex
28 Basic PHP Tutorial 8: Arithmatic Operators: Doing math with php
Basic PHP Tutorial 8: Arithmatic Operators: Doing math with php
sentdex
29 Basic PHP Tutorial 17: User Input Form Example / String Manipulation
Basic PHP Tutorial 17: User Input Form Example / String Manipulation
sentdex
30 Basic PHP Tutorial 18: HTML Entities and forms cont'd
Basic PHP Tutorial 18: HTML Entities and forms cont'd
sentdex
31 Basic PHP Tutorial 19: Finding words in strings
Basic PHP Tutorial 19: Finding words in strings
sentdex
32 Basic PHP Programming Tutorial 20: Saving to a File / writing and appending
Basic PHP Programming Tutorial 20: Saving to a File / writing and appending
sentdex
33 Basic PHP Programming Tutorial 22: Hashing part 2: salting
Basic PHP Programming Tutorial 22: Hashing part 2: salting
sentdex
34 Basic PHP Programming Tutorial 23: Variables in Strings and tokenizing
Basic PHP Programming Tutorial 23: Variables in Strings and tokenizing
sentdex
35 Basic PHP Programming Tutorial 21: MD5 Hashing For Security
Basic PHP Programming Tutorial 21: MD5 Hashing For Security
sentdex
36 Basic PHP Programming Tutorial 24: String similarity
Basic PHP Programming Tutorial 24: String similarity
sentdex
37 Basic PHP Programming Tutorial 25: Time and Time stamps
Basic PHP Programming Tutorial 25: Time and Time stamps
sentdex
38 Basic PHP Programming Tutorial 26: Die and Exit
Basic PHP Programming Tutorial 26: Die and Exit
sentdex
39 Basic PHP Programming Tutorial 27: MySQL Databases Part 1
Basic PHP Programming Tutorial 27: MySQL Databases Part 1
sentdex
40 Basic PHP Programming Tutorial 28: MySQL Database Part 2: Reading From Database
Basic PHP Programming Tutorial 28: MySQL Database Part 2: Reading From Database
sentdex
41 Basic PHP Programming Tutorial 29: MySQL Database Part 3: Inputting Data
Basic PHP Programming Tutorial 29: MySQL Database Part 3: Inputting Data
sentdex
42 Basic PHP Programming Tutorial 30: MySQL database in Use
Basic PHP Programming Tutorial 30: MySQL database in Use
sentdex
43 Django Tutorial Web Development with Python Part 1: Installing Django
Django Tutorial Web Development with Python Part 1: Installing Django
sentdex
44 Python Tutorial: File Deletion and Folder Deletion / directory deletion
Python Tutorial: File Deletion and Folder Deletion / directory deletion
sentdex
45 Python Tutorial: How to Rename Files and Move Files with Python
Python Tutorial: How to Rename Files and Move Files with Python
sentdex
46 3D Graphs in Matplotlib for Python: Basic 3D Line
3D Graphs in Matplotlib for Python: Basic 3D Line
sentdex
3D Plotting in Matplotlib for Python: 3D Scatter Plot
3D Plotting in Matplotlib for Python: 3D Scatter Plot
sentdex
48 3D Charts in Matplotlib for Python: Multiple datasets scatter plot
3D Charts in Matplotlib for Python: Multiple datasets scatter plot
sentdex
49 Sikuli Tutorial 1: Visually programming in python!
Sikuli Tutorial 1: Visually programming in python!
sentdex
50 Sikuli Tutorial 2: Program visually in python!
Sikuli Tutorial 2: Program visually in python!
sentdex
51 Sikuli Tutorial 3: Program visually in python!
Sikuli Tutorial 3: Program visually in python!
sentdex
52 3D Bar Charts in Python and Matplotlib
3D Bar Charts in Python and Matplotlib
sentdex
53 3D Plane wire frame Graph Chart in Python
3D Plane wire frame Graph Chart in Python
sentdex
54 Raspberry Pi Part 1 Introduction
Raspberry Pi Part 1 Introduction
sentdex
55 Raspberry Pi Part 8: First Download and Update! (Firmware)
Raspberry Pi Part 8: First Download and Update! (Firmware)
sentdex
56 Raspberry Pi Part 10: How to set up a Linux Web Server on your Pi
Raspberry Pi Part 10: How to set up a Linux Web Server on your Pi
sentdex
57 Raspberry Pi Part 11: Remote Desktop
Raspberry Pi Part 11: Remote Desktop
sentdex
58 Twitter Analysis: How to rank a user's influence
Twitter Analysis: How to rank a user's influence
sentdex
59 GPIO Tutorial for Pi Part 2 - Programming the GPIO
GPIO Tutorial for Pi Part 2 - Programming the GPIO
sentdex
60 GPIO Tutorial for Raspberry Pi Part 1 - Setting up
GPIO Tutorial for Raspberry Pi Part 1 - Setting up
sentdex

Related Reads

Up next
monday.com Automation: Fix Missing Emails in Seconds
Mastering monday
Watch →