MATPLOTLIB 3D PLOTS including Scatter 3D and Surface Plots for Matplotlib Python || Matplotlib Tips

Поділитися
Вставка
  • Опубліковано 21 лип 2024
  • Learn how to build matplotlib 3D plots in this Matplotlib Tips video including 3D scatter plots, 3D line plots, surface plots, and wireframes. I begin by showing you how to set up your 3D axes using the projection keyword. Then we plot 3D scatter plot data with matplotlib Python's scatter3D command and label the x, y, and z axes. I also show you how to rotate the view angle of the 3D plot in matplotlib using view_init. Next I show you an example of the 3D line plot in matplotlib using plot3D. We then move on to plot surfaces using a function for z and a meshgrid for x and y. And I also demonstrate how to create a 3-dimensional wireframe with matplotlib and how your grid effects your mesh size. Finally, we use the Jupyter magic command "% matplotlib notebook" to make our 3D plots interactive. You can use your mouse to drag the plot around and rotate it to look at different angles.
    0:00 Introduction
    0:12 3D Scatter Plot
    2:42 Rotate Plot Angle
    3:58 3D Line Plot
    4:58 Surface Plots
    8:19 Wireframes
    9:35 Interactive 3D Plots
    10:58 DANCE PARTY!
    GitHub Code:
    github.com/kimfetti/Videos/bl...
    Related Videos:
    * Change Matplotlib Figure Size: • How to change the matp...
    * Full Matplotlib Tips PLAYLIST: • Matplotlib Tips
    #matplotlib #dataviz
  • Наука та технологія

КОМЕНТАРІ • 54

  • @victorcouloume6824
    @victorcouloume6824 2 роки тому +3

    Thank you so much ! I was looking for an explanation this clear, keep the good work !

  • @BrunoAraujo-po2lm
    @BrunoAraujo-po2lm 3 роки тому +5

    Omg, I'm a 3D modeler, this video means so much to me, thank you! It's a normal distribution represented in 3D, genious!

  • @vitorrosar3251
    @vitorrosar3251 2 роки тому

    This is the best video about 3d graphics on matplotlib!!!

  • @zakariaabderrahmanesadelao3048

    Brilliant and clear tutorial, appreciated.

  • @rabinthapa401
    @rabinthapa401 2 роки тому

    Still on the middle of the document, Me studying this, I already admire it through all dimension. Thank you

  • @vitorribeirosa
    @vitorribeirosa Рік тому

    Thank you for you videos. They have helped me a lot.
    Cheers!!!

  • @higheloguy9057
    @higheloguy9057 2 роки тому

    Great professionally made video.
    You look great/alive in front of camera

  • @lucapassani1129
    @lucapassani1129 3 роки тому

    Very instructive and enjoyable. Thank you.

    • @KimberlyFessel
      @KimberlyFessel  3 роки тому +1

      Thanks so much, Luca! Glad you enjoyed it 😄

  • @hazhir3861
    @hazhir3861 2 роки тому

    That was helpful. Thank you for sharing :)

  • @samuelgbashi8969
    @samuelgbashi8969 Рік тому

    Great Job. I love your content.

  • @matteobarnaba6518
    @matteobarnaba6518 2 роки тому +1

    Thank you very much for your videos, they are great and very informative.
    Do you plan to make some video about contours, color maps, etc., as well?
    Thank you in advance for your reply 🙂

  • @stlo0309
    @stlo0309 2 роки тому

    tysm! never knew 3d plots are possible with matplotlib alone

  • @gusinthecloud
    @gusinthecloud 2 роки тому

    I really appreciate your video. It's quite helpful

  • @agustindelpino6898
    @agustindelpino6898 2 роки тому

    Que grande esta señora. Una capa.

  • @ayenewyihune
    @ayenewyihune 2 роки тому

    Great video, thank you

  • @SumandeepSinghRanamem
    @SumandeepSinghRanamem Рік тому

    thank you this was very nicely explained.

  • @user-rm2wr8nb6v
    @user-rm2wr8nb6v 2 роки тому

    Thank you very much!

  • @abdullahimuhammad643
    @abdullahimuhammad643 3 роки тому

    very useful. clarity defined this presentation

    • @KimberlyFessel
      @KimberlyFessel  3 роки тому

      Oh thank you! Glad to hear you found it to be clear - cheers!

  • @themightyquinn100
    @themightyquinn100 2 роки тому

    How do you include scatter data and surface on one plot? I have data points in 3 dimensions and I need to plot a surface that was obtained by B-Spline regression along with the data points.

  • @thbdf3879
    @thbdf3879 2 роки тому

    Really helpful !!!

  • @BISWAJITMONDAL-vj3py
    @BISWAJITMONDAL-vj3py 2 роки тому +1

    How to make two surface plots in 3D with different x & y scales (like twin axis in 2D plots)? ...Thanks!

  • @neelsamshah
    @neelsamshah 3 роки тому +1

    Thank you for creating this video. It is very helpful. In some of the code online, I see the following import: from mpl_toolkits import mplot3d. Is this needed? Also, sometimes, people explicitly create a figure using plt.figure and then add axes to the figure: fig = plt.figure();
    ax = plt.axes(projection='3d'). When do we need to explicitly use the figure function first?

    • @KimberlyFessel
      @KimberlyFessel  3 роки тому

      Most welcome! Regarding your questions: previous versions of matplotlib required you to explicitly import mplot3d to make a 3D plot. It won't hurt your code, but matplotlib version 3.2.0 or higher no longer requires this. And you can use fig = plt.figure() and then refer to that specific figure if you are creating multiple figures with your code. Really, any time the figure (or axes) you are referring to may be ambiguous.

  • @tilkesh
    @tilkesh 9 місяців тому

    Thanks

  • @darklee1146
    @darklee1146 2 роки тому

    excuseme sir, why i try to sketch another equation but the output the the same like your equation 50-x^2-y^2 ?

  • @youcefyahiaoui1465
    @youcefyahiaoui1465 2 роки тому

    Hi Kimberly,
    Again, thank you so much for the top notch videos you're putting out. I am definitely a fan. Now, often we define the z_line as a real time axis like say I have frequency 1MHz, its period would be 1/f = 1µs, I want to build an axis of 4 periods, I want the z_line to be my time t formed as 0 to 4*T with steps of T/10. Linespace does not work as it's expecting intergers. Can you advise on how to do the same thing as linspace but with float numbers? something that would like linspace(0,T/10,4*T)...

    • @youcefyahiaoui1465
      @youcefyahiaoui1465 2 роки тому

      Never mind, Kimberly. I was able to do this using np.arange(min, max, step) utility. Thanks.

  • @prabup3114
    @prabup3114 3 роки тому

    Very nice hands on. have a query. How to create a surface with x,y,z data points instead of knowing the z equation as a function of x,y.

    • @KimberlyFessel
      @KimberlyFessel  3 роки тому

      Thank you and sure thing! If you already have the values for z, you can just pass them directly into the surface plot; for example, ax.plot_surface(X, Y, Z) where Z contains your values instead of a function result. You'll just want to make sure that X, Y, and Z are all the same shape. Z should be the z-positions at all of your x- and y-grid positions.

  • @SURAJITHDE
    @SURAJITHDE Рік тому

    Ma'am can we create 3d surface plot by taking a grayscale image as an input

  • @guaishouxiao1623
    @guaishouxiao1623 2 роки тому

    plt.axes(projection="3d"), it says TypeError: 'module' object is not callable. Anyone has the same problem?

  • @nothing-yt7nu
    @nothing-yt7nu Рік тому

    When I try the interactive thing by adding"%matplotlib notebook", it returns an error that says "No module named 'ipympl'".

  • @belenmatamoros1078
    @belenmatamoros1078 9 місяців тому

    Te amo

  • @shajiwang
    @shajiwang 2 місяці тому

    is it possible to create a scatter 3D plot where the axis form a pyramid ladder chart instead of a cubic shape?

    • @KimberlyFessel
      @KimberlyFessel  2 місяці тому

      Sure, I don't see why not. You would just want to supply an equation for the pyramid shape instead of the cubic shape I have here in the definition of function_z()... may need a piecewise function to make the edges nice and crisp.

  • @aditijain6551
    @aditijain6551 3 роки тому

    once u move plot interactively, how to query new angles?

    • @KimberlyFessel
      @KimberlyFessel  3 роки тому

      Hi there - You can still use ax.view_init() even if you have interactive mode on ("%matplotlib notebook"). Just add ax.view_init() under your plot and re-run the cell. This will start the initial position of your figure at the angle you specify.

  • @davidzamora4654
    @davidzamora4654 2 роки тому

    How can I enable the "interactivity" mode in Spyder? Is it possible? Excellent video and explanation btw

    • @KimberlyFessel
      @KimberlyFessel  2 роки тому

      Thank you! Unfortunately, I'm not very familiar with Spyder, but it sounds like it is possible to do this based on @HABIBE KABA DIAKITE 's question and comment.

    • @_MrSivakumaR_
      @_MrSivakumaR_ 2 роки тому

      Interactive mode is not available in spyder, I think !
      However, you can run the program file from the file explorer, so that a new window opens, which is Interactive 🙂

  • @YM-lm8xr
    @YM-lm8xr 3 роки тому

    how to implement plotting a SERIES of 2d spectra(energy vs conductance) into a 3D plot (x=energy, y=uniformly lined up spectra, z=conductance) in Matplotlib?

    • @KimberlyFessel
      @KimberlyFessel  3 роки тому +1

      Hi there - as long as you have x, y, and z coordinates for each of these components, you can absolutely make a 3D plot for your data. Are your uniform spectra data currently the index of your series? If so, you can pass the dataframe columns and indices directly into the matplotlib plotting methods like scatter3D. For example, if you have a dataframe df with columns like "energy" and "conductance" and your spectra are the indices, you can do ax.scatter3D(df.energy, df.index, df.conductance).

  • @habibekabadiakite1218
    @habibekabadiakite1218 3 роки тому +1

    How to make the move on Spyder ?

    • @KimberlyFessel
      @KimberlyFessel  3 роки тому +1

      Hello there - unfortunately, I'm not too familiar with Spyder and don't have it installed on my machine. I typically test out this code using Jupyter Notebook or Google Colab. Sorry I couldn't help with this one!

    • @habibekabadiakite1218
      @habibekabadiakite1218 3 роки тому

      @@KimberlyFessel Thank you very much, I searched and I found

    • @shardulnikam9322
      @shardulnikam9322 3 роки тому

      @@habibekabadiakite1218 Hey, can you please share how to do it in spyder?

  • @sethsm7
    @sethsm7 2 роки тому

    DOES ANYBODY KNOW HOW TO PLOT Y AND Z-AXIS ON LOG SCALES WITHOUT APPLYING A LOG TO THE DATA?? PLEASE AND THANK YOU!!

    • @LetoTheGodEmperor
      @LetoTheGodEmperor 2 роки тому

      You could try ax.set_yscale('log') and ax.set_zscale('log'). Hope it works

  • @Andrumen01
    @Andrumen01 Рік тому

    It's good that matplotlib has 3D options...but still so far from being good...I always feel that it could be better but it never quite gets there. There should be lessons learned from Mathematica. Understandable that Mathematica is paid software, whereas matplolib is "free", but still disappoints a little every time I try to use it.