Тёмный

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

Kimberly Fessel
Подписаться 20 тыс.
Просмотров 43 тыс.
50% 1

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

Наука

Опубликовано:

 

27 июн 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 57   
@BrunoAraujo-po2lm
@BrunoAraujo-po2lm 3 года назад
Omg, I'm a 3D modeler, this video means so much to me, thank you! It's a normal distribution represented in 3D, genious!
@KimberlyFessel
@KimberlyFessel 2 года назад
Nice 😄-- 3D plots are so much fun!
@victorcouloume6824
@victorcouloume6824 2 года назад
Thank you so much ! I was looking for an explanation this clear, keep the good work !
@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!!!
@stlo0309
@stlo0309 2 года назад
tysm! never knew 3d plots are possible with matplotlib alone
@hazhir3861
@hazhir3861 2 года назад
That was helpful. Thank you for sharing :)
@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 года назад
Thanks so much, Luca! Glad you enjoyed it 😄
@gusinthecloud
@gusinthecloud 2 года назад
I really appreciate your video. It's quite helpful
@samuelgbashi8969
@samuelgbashi8969 Год назад
Great Job. I love your content.
@ayenewyihune
@ayenewyihune 2 года назад
Great video, thank you
@SumandeepSinghRanamem
@SumandeepSinghRanamem Год назад
thank you this was very nicely explained.
@agustindelpino6898
@agustindelpino6898 2 года назад
Que grande esta señora. Una capa.
@user-rm2wr8nb6v
@user-rm2wr8nb6v 2 года назад
Thank you very much!
@matteobarnaba6518
@matteobarnaba6518 2 года назад
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 🙂
@thbdf3879
@thbdf3879 2 года назад
Really helpful !!!
@KimberlyFessel
@KimberlyFessel 2 года назад
Very glad to hear that - cheers!
@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!
@tilkesh
@tilkesh 8 месяцев назад
Thanks
@neelsamshah
@neelsamshah 2 года назад
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 2 года назад
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.
@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.
@BISWAJITMONDAL-vj3py
@BISWAJITMONDAL-vj3py 2 года назад
How to make two surface plots in 3D with different x & y scales (like twin axis in 2D plots)? ...Thanks!
@belenmatamoros1078
@belenmatamoros1078 8 месяцев назад
Te amo
@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.
@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.
@whimsicalvibes
@whimsicalvibes 3 года назад
Thanks. was very helpful. I have an df, which has multiple columns. say X,Y,Z,AMP I converted X,Y,Z, AMP to numpy arrays as: arrayX = df['X'].values now I plotted X,Y,Z but want to color the scatterplot usiing AMP...AMP varies between -5000 to +5000 how to do this? Can you help?
@whimsicalvibes
@whimsicalvibes 3 года назад
alright I could do it ... ax.scatter3D(arrayX,arrayY,arrayZ,c=arrayAmp, cmap ='bwr') Thanks for the great vid.
@KimberlyFessel
@KimberlyFessel 2 года назад
Yes - that's exactly correct! Glad to see you figured it out - cheers!
@SURAJITHDE
@SURAJITHDE Год назад
Ma'am can we create 3d surface plot by taking a grayscale image as an input
@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 ?
@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 🙂
@shajiwang
@shajiwang Месяц назад
is it possible to create a scatter 3D plot where the axis form a pyramid ladder chart instead of a cubic shape?
@KimberlyFessel
@KimberlyFessel Месяц назад
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.
@nothing-yt7nu
@nothing-yt7nu Год назад
When I try the interactive thing by adding"%matplotlib notebook", it returns an error that says "No module named 'ipympl'".
@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.
@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 2 года назад
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).
@guaishouxiao1623
@guaishouxiao1623 2 года назад
plt.axes(projection="3d"), it says TypeError: 'module' object is not callable. Anyone has the same problem?
@habibekabadiakite1218
@habibekabadiakite1218 3 года назад
How to make the move on Spyder ?
@KimberlyFessel
@KimberlyFessel 3 года назад
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 2 года назад
@@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 11 месяцев назад
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.
Далее
I Built a SECRET McDonald’s In My Room!
36:00
Просмотров 8 млн
Seaborn Is The Easier Matplotlib
22:39
Просмотров 161 тыс.
7 Python Data Visualization Libraries in 15 minutes
15:03
Creating Vector Field Plots in Python with Matplotlib
19:00
Pydantic Tutorial • Solving Python's Biggest Problem
11:07
ПОКУПКА ТЕЛЕФОНА С АВИТО?🤭
1:00