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