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

แชร์
ฝัง
  • เผยแพร่เมื่อ 31 ม.ค. 2025

ความคิดเห็น • 53

  • @Elzelgator
    @Elzelgator 5 ปีที่แล้ว

    Mate, you are the best python developer in youtube?

  • @ticTHEhero
    @ticTHEhero 6 ปีที่แล้ว

    Intro is very satisfying

  • @datascienceds7965
    @datascienceds7965 7 ปีที่แล้ว +2

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

  • @xenyatox9814
    @xenyatox9814 4 ปีที่แล้ว +2

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

  • @MH-oc4de
    @MH-oc4de 6 ปีที่แล้ว

    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.

  • @ArnonoBen
    @ArnonoBen 7 ปีที่แล้ว +5

    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 !

    • @Buddha1245
      @Buddha1245 5 ปีที่แล้ว

      I want to know too, did you find out?

    • @agentNirmites
      @agentNirmites 5 ปีที่แล้ว

      Yes, but if you have an inline plot, then you might not do that. (Probably)

  • @sachingoyal9620
    @sachingoyal9620 7 ปีที่แล้ว +1

    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?

  • @earlgreen8943
    @earlgreen8943 10 ปีที่แล้ว

    This is so cool. I might try this out now

  • @unturned6066
    @unturned6066 10 ปีที่แล้ว +2

    Thanks for this. It helped me a lot!

    • @sentdex
      @sentdex  10 ปีที่แล้ว +1

      Great to hear

  • @NoelBrizuela
    @NoelBrizuela 9 ปีที่แล้ว

    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.

  • @103798
    @103798 5 ปีที่แล้ว

    Thx, quickest way to do this.

  • @philiperiskallaleal6010
    @philiperiskallaleal6010 6 ปีที่แล้ว

    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

    • @agentNirmites
      @agentNirmites 5 ปีที่แล้ว +1

      I can't understand how will it be visualized ?

  • @jcl7987
    @jcl7987 11 ปีที่แล้ว +3

    Hi I love your tutorial! I have a question, I'm trying to plot scatter points in 3D space with updating, do you have any suggestion for that? :)

  • @chrisrichards7825
    @chrisrichards7825 10 ปีที่แล้ว

    Excellent. Thanks for this! Very helpful

  • @aeromateen6773
    @aeromateen6773 5 ปีที่แล้ว

    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.

  • @botelhorui
    @botelhorui 10 ปีที่แล้ว

    thank you for sharing. Not even excel,matlab,mathematica have a good plot 3d like this simple program.

  • @agentNirmites
    @agentNirmites 5 ปีที่แล้ว +1

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

    • @ichias16
      @ichias16 5 ปีที่แล้ว +1

      he answers that at 4:22
      it basically shows how close each indvidual dot is to the viewer

    • @agentNirmites
      @agentNirmites 5 ปีที่แล้ว

      @@ichias16 Yeah, thanks.

  • @josephsylvan6511
    @josephsylvan6511 4 ปีที่แล้ว

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

  • @nickyeh7585
    @nickyeh7585 4 ปีที่แล้ว

    You are so amazing! thanks a lot!

  • @sagarhm2237
    @sagarhm2237 4 ปีที่แล้ว

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

  • @go1chase1the1sun1set
    @go1chase1the1sun1set 3 ปีที่แล้ว

    Hi can I do this with RGB values?
    X = [1,2,3,4]
    Y = [1,2,3,4]
    Z = [1,2,3,4]
    C = np.array([[0, 0, 0], [0, 0, 128], [255, 255, 102],[0, 7, 65]])
    fig = plt.figure()
    ax = fig.add_subplot(111, projection = '3d')
    ax.scatter(X, Y, Z, c = C/255.0)
    ax.set_xlabel('x axis')
    ax.set_ylabel('y axis')
    ax.set_zlabel('z axis')
    plt.show()
    this but place my whole RGB colour list in C parameter? And changew X, Y, Z to n=(how many are in the list)

  • @selvakarna6264
    @selvakarna6264 5 ปีที่แล้ว

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

  • @RD-yv4cc
    @RD-yv4cc 6 ปีที่แล้ว +1

    How do you rotate your images? IDE specific maybe?

    • @agentNirmites
      @agentNirmites 5 ปีที่แล้ว +1

      No, just drag. If you are using a notebook, and if you have inline plot, you might not rotate...

    • @hamzazanagui6471
      @hamzazanagui6471 4 ปีที่แล้ว

      add this to notebook
      and it will rotate :
      %matplotlib
      # rotate the axes and update
      for angle in range(0, 360):
      ax.view_init(30, angle)
      plt.draw()

  • @epaillas
    @epaillas 10 ปีที่แล้ว

    Thank you, this was useful.

    • @sentdex
      @sentdex  10 ปีที่แล้ว

      Happy to share!

  • @igorfomenko9189
    @igorfomenko9189 6 ปีที่แล้ว

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

  • @RizwanKhan-ut8zq
    @RizwanKhan-ut8zq 9 ปีที่แล้ว

    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
      @sentdex  9 ปีที่แล้ว

      Rizwan Khan Matplotlib and Python are their own things entirely, separate from matlab.

    • @RizwanKhan-ut8zq
      @RizwanKhan-ut8zq 9 ปีที่แล้ว

      yeah i got it now. your tutorials are helpful. Thank you.
      Could you please upload a tutorial to read XYZ data from a file and make a plot like this one?

  • @sorayaanvari5906
    @sorayaanvari5906 7 ปีที่แล้ว

    you are the best. thank you very much

  • @gyarreto
    @gyarreto 5 ปีที่แล้ว

    it doesnt work with jupyter notebook?

    • @sentdex
      @sentdex  5 ปีที่แล้ว

      Since notebook doesnt show. You can try the %matplotlib inline magic and maybe that'll help

    • @gyarreto
      @gyarreto 5 ปีที่แล้ว

      @@sentdex Hi, I Have actually made it worked as the tutorial showed. But now I'm trying to plot with my own dataset, and it tells me an error "shape mismatch: objects cannot be broadcast to a single shape",
      arguably Im using a very messy data, as in the XYZ I now use is;
      endingMerchantSales = [100,639,3068,14727,70692,339325,1628777,7818186]
      salesPL = [24500,133164.4,384675.168,1546967.643,6225678.340,29571844.556,129179928.610,612495651.837]
      salesMultiplier = [ 16.33 , 21.47 , 23.97 , 26.52 , 26.52 , 27.79 , 27.79 ]
      as in those are my XYZ
      Do you know of any possible solution to this? or maybe I should specified the range of each axis? would that help?

  • @danishsodhi2453
    @danishsodhi2453 8 ปีที่แล้ว

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

    • @sentdex
      @sentdex  8 ปีที่แล้ว

      +danish sodhi You cannot embed a matplotlib interactive graph in html like this. You might be able to find some sort of javascript emulator for matplotlib, but that'd be messy. you're better off implementing something like: www.highcharts.com/demo/3d-scatter-draggable
      For implementing highcharts example: pythonprogramming.net/adding-js-plugins-flask-highcharts-example/

    • @StreetDogWrangler
      @StreetDogWrangler 8 ปีที่แล้ว

      +sentdex Can highcharts handle millions of data points?

    • @agentNirmites
      @agentNirmites 5 ปีที่แล้ว +1

      you can. Save a graph as a file and then put in html...

    • @agentNirmites
      @agentNirmites 5 ปีที่แล้ว +1

      @@StreetDogWrangler yes

  • @phadadev2307
    @phadadev2307 5 ปีที่แล้ว

    Many thanks.

  • @jesus2621
    @jesus2621 3 ปีที่แล้ว

    dude if you know we use data from a file why you keed doing it like the manuals ffs

  • @andreitimofte5339
    @andreitimofte5339 6 ปีที่แล้ว

    thank you so much! :)

  • @bilimgilim7266
    @bilimgilim7266 10 ปีที่แล้ว

    Thank you. This relay help me. But to how make it dynamic?
    I want to make it read x,y and z position from file, each row in file is one frame and three columns corresponding to x,y,z.
    This is my file looks like:
    1 1 1
    1 7 3
    4 2 4
    This is my file
    fig = plt.figure()
    ax = fig.add_subplot(111, projection='3d')
    x = []; y = []; z=[];
    with open('3dplot.csv', 'rb') as csvfile:
    spamreader = csv.reader(csvfile, delimiter=',', quotechar='|')
    for row in spamreader:
    print row
    x.append(int(row[0]))
    y.append(int(row[1]))
    z.append(int(row[2]))
    ax.scatter(x,y,z,c='r',marker='o')
    ax.set_xlabel('x axis')
    ax.set_ylabel('y axis')
    ax.set_zlabel('z axis')
    plt.show()
    Thank you.