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




[ad_1]

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

Source


[ad_2]

Comment List

  • sentdex
    December 26, 2020

    Great video, thanks!

  • sentdex
    December 26, 2020

    If I want to create surface and join all points themselve how do I need to proceed

  • sentdex
    December 26, 2020

    I have graph network how do I plot it in 3d…what must be the values of Z axis for the graph?

  • sentdex
    December 26, 2020

    Sir how to get different markers in scatter plot without using subplots

  • sentdex
    December 26, 2020

    Thx, quickest way to do this.

  • sentdex
    December 26, 2020

    How can we add a categorical value to the points…say we have values for target 0 and 1 and we want to add that dimension too and color the plot.

  • sentdex
    December 26, 2020

    Why there are different red colors? We just specified one red color.

  • sentdex
    December 26, 2020

    Mate, you are the best python developer in youtube?

  • sentdex
    December 26, 2020

    Many thanks.

  • sentdex
    December 26, 2020

    Hey man, what do you use to move the plot around ? I did it in jupyter notebook but it printed a 3d plot i can't move so it's useless

  • sentdex
    December 26, 2020

    it doesnt work with jupyter notebook?

  • sentdex
    December 26, 2020

    how to convert from x y z to stl? using python scripts? or how to make vertics from x y z coordinate using python?

  • sentdex
    December 26, 2020

    hi, im using the same tool, but i dont need make a surface, i´m need make a 3D Scatter Plot with Python and Matplotlib, to my own data which it have longitude, latitude and depth, i have the cvs files whith of the three columns, but the code not read the cvs file, thanks

  • sentdex
    December 26, 2020

    Intro is very satisfying

  • sentdex
    December 26, 2020

    Is it also possible to find the volume from that shape ?

  • sentdex
    December 26, 2020

    Thanks, I didn't realize matplot already had myavi-like 3d plotting built in. For my system, it was necessary to change your import of "Axes3d" to "axes3d". Don't know if it changed or you have a case-insensitive python or something.

  • sentdex
    December 26, 2020

    Dear all,

    Thank you for the video.

    I was wondering whether one could apply the same concepts of your video in order to plot a 4D data (x= longitude, y=latitude, z=time, k=attribute value) in a 3D matplotlib structure. The color of the plot would be the Kth dimension, an alpha (transparency) parameter would be needed in order to be able to visualize the data within the data.

    Typical cases can be found in Astronomy and remote sensing science. Typical file formats that store that kind of info are NETCDF and HDF.

    I thank you for your time,

    Sincerely yours,

    Philipe Leal

  • sentdex
    December 26, 2020

    How do you rotate your images? IDE specific maybe?

  • sentdex
    December 26, 2020

    thank you so much! 🙂

  • sentdex
    December 26, 2020

    How to zoom, pan,how to change the center of rotation

  • sentdex
    December 26, 2020

    This is a very informative video. Thanks for posting. I was wondering how to do plot for float numbers?

  • sentdex
    December 26, 2020

    Hi ! Is it possible to rotate 3D plots by hand on jupyter ? It doesn't work on my side so I don't know if it's possible.
    Thanks !

  • sentdex
    December 26, 2020

    Hey, thanks for the great video, I have couple of queries:
    Q.) What is the limit of Matplotlib in terms of number of data points that can be printed? When I try with 50,000 data points it takes long time, after 1 lakh data item, it does not even show up? Are there any thresholds mentioned in documentation?

  • sentdex
    December 26, 2020

    you are the best. thank you very much <3 🙂

  • sentdex
    December 26, 2020

    Hey ,
    Can you please help in how can I embedd these 3D plots in HTML . I am using Flask framework .
    Thanks in advance 🙂

  • sentdex
    December 26, 2020

    Hey Harrison,
    I found it man….man I am gonna go and get drunk now!
    Anyhow…below is what I did, just in case some newbies struggling with that issue as well.

    ======================================================================================
    from mpl_toolkits.mplot3d import axes3d
    import matplotlib.pyplot as plt
    import csv

    fig = plt.figure()
    ax = fig.add_subplot(111, projection='3d')

    x=[]
    y=[]
    z=[]

    with open(r'C:…oeo2.csv') as file:
    plots=csv.reader(file, delimiter=',')
    for row in plots:

    x.append(float(row[0]))
    y.append(float(row[1]))
    z.append(float(row[2]))

    ax.scatter(x,y,z, c='r', marker='o')
    plt.show()
    ======================================================================================

    cheers,

  • sentdex
    December 26, 2020

    Hey Harisson,
    I'd like to run a question.
    The example is perfectly fine with those X, Y and Z values, but how do I import data from a directory path into it? I mean I have an txt/csv file with x,y and z values. How to import them

    =====================================================================================
    from mpl_toolkits.mplot3d import Axes3D
    import matplotlib.pyplot as plt
    import numpy as np

    fig = plt.figure()
    ax = fig.add_subplot(111, projection='3d')

    x,y,z = np.loadtxt(r'C:UsersavgitidiDesktopProfKadaRadioHead_HouseCardsHA_1oeo2.csv',
    unpack=True,
    delimiter=',')

    for column in x,y,z:
    print column

    ax.scatter(x,y,z, marker='o')
    plt.show()
    =====================================================================================

    and what I get is:
    delimiter=',')
    ValueError: need more than 2 values to unpack.

    How do I solve it? Thanks in advance.

    ohh…and my values look like this"

    -64.1779 -59.3591 -51.2079
    112.7049 114.3296 101.6864
    -274.358 -255.1 -208.914

    etc. etc.

    cheers,

  • sentdex
    December 26, 2020

    Dear Sentdex, I am new to matlab and these plotting softwares, I have a text file and I am interested in plotting the xyz in a 3d scatter plot. I have followed your tutorial ans I have installed matplot along with NUMpy and everything. I was thinking that it works with matlab as a tool. but I could not make it work. its been my 3rd day and i have wasted a lot of time. a little help would save me more time. thanking you in anticipation.

  • sentdex
    December 26, 2020

    Thank you so much for all your tutorials, they've been super helpful. Do you happen to have any video on graphing surfaces from xyz points? Sort of like spline (u did the smoothing video for 2D) but for 3D. I haven't been able to find it among your videos. 

  • sentdex
    December 26, 2020

    This is so cool.  I might try this out now

  • sentdex
    December 26, 2020

    Excellent. Thanks for this! Very helpful

  • sentdex
    December 26, 2020

    Thanks for this. It helped me a lot!

Write a comment