TABLE OF CONTENTS 00:00 Intro 00:32 Importing 02:38 Simple Plotting 04:52 Multiple Plots 06:08 Using Figure Objects 12:32 Subplots 15:03 Appearance Options 21:28 Saving Plots 22:09 Working with Pandas Dataframe 29:01 TeX Markup (Math Symbols) 36:41 Histograms 40:57 Bar Charts 48:19 Pie Charts 53:50 Timeseries 59:31 Tables 1:08:21 Scatterplots 1:12:59 3D Surfaces 1:21:38 Matplotlib Finance 1:26:23 Heatmaps Probability in One Video : ruclips.net/video/sEte4hXEgJ8/видео.html Statistics in One Video : ruclips.net/video/tcusIOfI_GM/видео.html NumPy in One Video : ruclips.net/video/8Y0qQEh7dJg/видео.html Pandas in One Video : ruclips.net/video/PcvsOaixUh8/видео.html
1:33:45 Stayed til the end. Have an enormous project with a crazy learning curve ahead. I don’t plan on using matplotlib but I wanted to learn it before PlotLy to get a second perspective.
The college professor you wished you had! To say Derek knows his stuff is just a bit understated. Video moves rapidly covering many visualization possibilities using Jupyter notebook. One of the hurdles I've had with Matplotlib is that there are actually too many possibilities with disjointed specifics. The pace, logical progression and scope of this video is perfect, leaving the viewer with functioning code examples to run, modify and explore on their own. Bravo!
WOW , that was a really through class!!! I know that you din't dive too deep on every module, but it actually is not neeeded . anyone wanting to learn Python will find he's way, all we need is this headstart!!
This is a fantastic tutorial. Even though I have a lot of experience in plotting using Excel and PowerBI, for reasons unknown, I've always felt intimidated by the idea of plotting using python. From your video, I've gained a lot of knowledge and confidence, thank you so much for your effort. Also, many thanks for the ipynb file, much appreciated. Next stop - Seaborn Tutorial :-)
This is great, the info comes at you so fast... Basically you see what is possible then when you need to actually use it you come back and pause the video and copy the code :D
I just watched your Plotly and matplotlib tutorials, they are awesome, I' heading to watch the seaborn , numpy and and the other cool videos you have! Keep the great work, greetings from Mexico
This series has come up at a fantastic time in the Data Science / Machine Learning space. As a software engineer myself with weaker background in mathematics, trying to prepare for the future in this field has always been daunting. These video tutorials, along with the statistics series are extremely valuable to making this area more accessible & fun to learn - thank you @Derek Banas !
Thank you :) I’m doing my best to create a step-by-step course while also trying to present everything in new ways. I’ve been using data science for work for quite some time so I have my core toolset. I will however try to cover everything to the best of my ability. For example I mainly use PyTorch, but I’ll cover Tensorflow as well.
Your teaching method is just great! I love the way you are teaching Sir. I recently purchased a Data Science course in Udemy from Jose Portilla, but his teaching method is not interesting to me at least. And I wanted to say that I rarely comment on videos on RUclips, and those are the ones I liked a lot like this video! Bravo!!!
Thanks for nice tutorial! Some shorthand for rounding in Tabels section: df.iloc[:, 1:6] = round(df.iloc[:, 1:6], 2) This line of code would round all values in all price columns
Watched the whole video, although I skipped some details since I am quite familiar with matplotlib. I liked slower pace of the video, it made it easy to casually watch the video without my full attention. I am looking forward to seaborn, which i have not used it yet, so you will have my full attention. Thank you very much for your videos, the amount and breadth of topics you are able to cover is amazing.
Thank you for the input. Yes I just slightly slowed the video to see if anyone noticed. I appreciate both that you watched the video and that you said you preferred the slower speed I'll keep doing it. Yes Seaborn is next. It should be up in less than 6 days.
@@derekbanas One questions, I have struggled to save the file, as it does not show the axes (and I noticed it does not show it in your video either) any thoughts on how to get the axes to show on the saved file?
At 23:50, why do we need to convert the pandas dataframe to a numpy array. Isn't pandas based on numpy. Also, many stackexchange posts suggest that .values (is this an attribute?) is not recommended to do this. They suggest using the function Dataframe to numpy() instead. At 38:10, why are you choosing stacked=True if there is only one data set for the histogram. Isn't this redundant (and kinda confusing)? At 48:10, surely you need to change the tick labels back form the index to the school types again using xticks(ticks, labels) etc?
The syntax for subplotting is incredibly confusing. There are various functions e.g. subplot(), subplots(), add_subplot() or the axes() functions, all used in a variety of ways e.g. some as part of the module plt in plt.subplots() or plt.subplot() here and some as a method acting on the figure e.g. fig.add_subplots. Then there's the various and confusing indices for the arguments. For example, around 5:15, couldn't you first just assign plt.subplot() with its arguments to a variable e.g. ax1 and then on the next line have ax1.plot() with it's arguments. The reason I say this is that I can't understand how plt.plot() with its arguments knows how to work on the specific axis plt.subplot() etc on the line above it. I suspect fig.add_subplots is the best way to create subplots, but every video seems to do it differently. Surely at 11:50, the arguments for positioning the text for axes2 are based not on the centre of the figure being (0,0) as you say, but on the origin of axis 2 being (0,0). If you see where the text ends up, this is clear (around (0,40) relative to the axis 2 origin).
Thank you for this. At 12:20, is there any good reason why the add_axes() method takes a list as argument, yet the text() method takes a tuple. It seems totally arbitrary since the arguments are both related to location etc.
At 7:20 , I can't get this code to run: `fig1 = plt.figure(figsize(5,4),dpi =100)` Error: NameError Traceback (most recent call last) Input In [7], in () ----> 1 fig1 = plt.figure(figsize(5,4),dpi =100) Any idea what I have wrong here?
Chatgpt solved it: fig1 = plt.figure(figsize=(5,4),dpi=100) Explanation below -> 'The issue with your code is that you have specified the figsize argument incorrectly. The figsize argument expects a tuple of width and height values, but in your code, you have specified it as two separate values. To fix this issue, you can modify your code as follows: import matplotlib.pyplot as plt fig1 = plt.figure(figsize=(5,4), dpi=100) axes_1 = fig1.add_axes([0.1, 0.1, 0.9, 0.9]) axes_1.set_xlabel("x-axis label") plt.show() Thanks chatpgt
top-notch tutorial as always. Thank you so much, man. You are my motivation that keeps me productive every day. BTW, I just noticed that your typing speed is getting slow. But I still like your content tho.
Hey Derek you are amazing I have learnt a lot from your machine series if possible can make a video on sikit learn And machine learning algorithms in python with real-time examples that would be great!! Again, thanks a lot for your effort it really makes a difference load of love from india..
plt.scatter() plt.plot() plt.title() plt.xlabel() plt.ylabel() plt.show() plt is a module and all these scatter,plot,show are functions than how are they connected like where is the information from one function being stored so that another function can use it?? please answer me
in the timeseries section it shows the error that ValueError: x and y must have same first dimension, but have shapes (64,) and (251,) even after copying your code it does not seem to work What do you think might be the issue here im kinda stuck thanks
I have favour to ask you bro , Will Go deep into Descriptive Analytics along with Supervised Machine Learning? I don't get anything which My Teacher teaches and they don't put much effort in teaching us(that's sorry to say but it's true). And one thing I really like your "Machine Learning and Data Science " series and I know that there are more things to come in that series . So best of luck and i really hope that you will go as deeper as possible in this series .Best wishes with you Bro . Keep it up 👍👍💪
Thank you for the nice message :) Yes I have promised I will dedicate myself to data science, machine learning and the related maths for the rest of the year. My goal to to provide a complete learning path all at one location in order.
Would you ever consider doing a Dafny tutorial? I've have a very short introduction to it in one of my uni classes and thought it was interesting, and I'm sure it would help some people!
It would be great if you take some time and explain the installation procedure and troubleshooting at the beginning. I am using pip install, matplotlib is installed but it is showing error in import.
Thanks for another great video. It's probably me but I could not find the link to jupiter notebook you used in the video to run the examples. Could you please point me in the right direction if it is possible?
Thank you :) I show how to install everything for Windows here : ruclips.net/video/a7Ylbn1ikF0/видео.html and for Mac here which is basically the same for Linux ruclips.net/video/2JeoNlCcLOM/видео.html and at the end of my Pandas tutorial I talk about setting up virtual environments and installing libraries ruclips.net/video/PcvsOaixUh8/видео.html Sorry everything is all over the place. That is sort of the problem with trying to create a big course, while also making these learn in one videos.
@@derekbanas Thanks Derek for getting back to me. The video that you mentioned has a link to the Python codes that you used for the stats tutorial, but no codes for Matplotlib video that I am after. I found these on your web site www. newthinktank. com/2020/08/learn-matplotlib-one-video/ (remove spaces) where there was a link to your Github. Thanks again
How did you I will come to your page to find machine learning tutorials these days to upload these?! Thanks, I have never come back from your channel with absence.
Hey, thanks for the video, it's so well explained. For the Time Series section, I downloaded data from 21 Aug 2019 - 21 Aug 2020. I've done all the same code but when I put in plt.plot (date_arr_np, goog_cp) I get an error and this message: 'x and y must have same first dimension, but have shapes (64,) and (253,)'. Do you know what's gone wrong or how I can fix this?
@@derekbanas Same problem here, I managed to fix this example with your data, but in case of data I downloaded, it didn't work. Did you swith some other options on yahoo or something else? Anyway, thank you for your great work!
So I figured it out! Almost kids' joy here :) My solution was to extract the same amount of rows from downloaded material a then use it. It may not be the most elegant sulution, but it worked. goog_data = pd.read_csv('GOOG.csv') goog_data goog_data_np = goog_data.to_numpy() goog_cp = goog_data_np[:, 4] data = pd.DataFrame(goog_cp) rows = data.head(43).to_numpy() #odstranit svátky holidays = [datetime.datetime(2022, 11, 17), datetime.datetime(2022, 10, 28)] date_arr = pd.bdate_range(start='10/1/2022', end='12/4/22', freq='C', holidays=holidays) date_arr_np = date_arr.to_numpy() fig_7 = plt.figure(figsize=(8,5)) axes_7 = fig_7.add_axes([0.1, 0.1, 0.9, 0.9]) plt.plot(date_arr_np, rows)
Why is pandas, sometimes, but not always used in conjunction with matplotlib? Any suggestions on how to read/parse/plot a string from the (py)serial port, such that no data is dropped? The transmitter sends lines like "1.23, 3.3, 87.1 " every 500ms for approximately 2 minutes.. yet in the code below, the update to the plot seems to take too much time, because the data starts to get dropped (or gets backed up into a queue?), and does not get plotted nor csv saved . Is there more efficient way of plotting (animation) or using threads import serial import time import csv import threading import numpy as np import matplotlib matplotlib.use("tkAgg") import matplotlib.pyplot as plt #TODO : Use threads for Plot and Serial.. like ComPlotter or felipengeletrica /PyDatalogger ser = serial.Serial('/dev/ttyACM0') ser.flushInput() plot_window = 20 y_var = np.array(np.zeros([plot_window])) plt.ion() fig, ax = plt.subplots() line, = ax.plot(y_var) while True: try: ser_bytes = ser.readline() try: decoded_bytes = float(ser_bytes[0:len(ser_bytes)-2].decode("utf-8")) print(decoded_bytes) except: continue with open("test_data.csv","a") as f: writer = csv.writer(f,delimiter=",") writer.writerow([time.time(),decoded_bytes]) y_var = np.append(y_var,decoded_bytes) y_var = y_var[1:plot_window+1] line.set_ydata(y_var) ax.relim() ax.autoscale_view() fig.canvas.draw() fig.canvas.flush_events() except: print("Keyboard Interrupt") break ################################## ################################## ################################## def Main(): ser = None # serial.Serial(3, 11520) t1 = threading.Thread(target = Task1, args=[ser]) t2 = threading.Thread(target = Task2, args=[ser]) Report("Starting Thread 1") t1.start() time.sleep(3) Report("Starting Thread 2") t2.start() if __name__ == '__main__': Main() ################################## ################################## ################################## import serial import wx import numpy import matplotlib matplotlib.use('WXAgg') from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg from matplotlib.figure import Figure import matplotlib.pyplot as plt class DataLoggerWindow(wx.Frame): def __init__(self): wx.Frame.__init__(self, None, -1, "ComPlotter", (100,100), (640,480)) self.SetBackgroundColour('#ece9d8') # Flag variables self.isLogging = False # Create data buffers self.N = 100 self.n = range(self.N) self.M = 3 self.x = [] for m in range(self.M): self.x.append(0 * numpy.ones(self.N, numpy.int)) # Create plot area and axes self.fig = Figure(facecolor='#ece9d8') self.canvas = FigureCanvasWxAgg(self, -1, self.fig) self.canvas.SetPosition((0,0)) self.canvas.SetSize((640,320)) self.ax = self.fig.add_axes([0.08,0.1,0.86,0.8]) self.ax.autoscale(False) self.ax.set_xlim(0, 99) self.ax.set_ylim(-100, 1100) for m in range(self.M): self.ax.plot(self.n,self.x[m]) # Create text box for event logging self.log_text = wx.TextCtrl( self, -1, pos=(140,320), size=(465,100), style=wx.TE_MULTILINE) self.log_text.SetFont( wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.NORMAL, False)) # Create timer to read incoming data and scroll plot self.timer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.GetSample, self.timer) # Create start/stop button self.start_stop_button = wx.Button( self, label="Start", pos=(25,320), size=(100,100)) self.start_stop_button.SetFont( wx.Font(14, wx.DEFAULT, wx.NORMAL, wx.NORMAL, False)) self.start_stop_button.Bind( wx.EVT_BUTTON, self.onStartStopButton) def GetSample(self, event=None): # Get a line of text from the serial port sample_string = self.ser.readline() # Add the line to the log text box self.log_text.AppendText(sample_string) # If the line is the right length, parse it if len(sample_string) == 15: sample_string = sample_string[0:-1] sample_values = sample_string.split() for m in range(self.M): # get one value from sample value = int(sample_values[m]) self.x[m][0:99] = self.x[m][1:] self.x[m][99] = value # Update plot self.ax.cla() self.ax.autoscale(False) self.ax.set_xlim(0, self.N - 1) self.ax.set_ylim(-100, 1100) for m in range(self.M): self.ax.plot(self.n, self.x[m]) self.canvas.draw() def onStartStopButton(self, event): if not self.isLogging: self.isLogging = True self.ser = serial.Serial() self.ser.baudrate = 38400 self.ser.timeout=0.25 # Try serial ports one by one starting # with COM30 and working downwards for m in range(29, 0, -1): self.ser.port = m try: # Try this port number self.ser.open() # We only get to here if port opened self.log_text.AppendText( 'Opened COM' + str(m+1) + '... ') break except: # We end up here if this port number # failed to open pass if self.ser.isOpen(): # We successfully opened a port, so start # a timer to read incoming data self.timer.Start(100) self.start_stop_button.SetLabel("Stop") else: self.timer.Stop() self.ser.close() self.isLogging = False self.start_stop_button.SetLabel("Start") if __name__ == '__main__': app = wx.PySimpleApp() window = DataLoggerWindow() window.Show() app.MainLoop()
@@derekbanas it has it's own script language and api for other languages, also he has gui buttons and other staff. Classic is the full package including 3d 2d statistic and other staff.
Derek Banas thanks. Looking forward for the next videos. I found PyQtGraph visualisation to be faster than matplotlib especially for real time data/signals and at the same time, PyQtGraph is difficult to understand(for me :P)
@Derek Banas hey derek ive watched your java tutorial and i wanna be java backend programmer what should i learn after that i mean what concept should i learn first on java ee and actually u promise me to create Spring tutorial ?
Basically everything listed in the certification is required education.oracle.com/oracle-certified-professional-java-ee-7-application-developer/trackp_900
@@derekbanas i saw that but its little a bit counfusing u know could u cover it next tutorial i know u already created a java ee but its not enough i gues can u cover java ee i really need this and o already asked u to cover Spring too if u cover these topics your gonna change my life Thanks bro
TABLE OF CONTENTS
00:00 Intro
00:32 Importing
02:38 Simple Plotting
04:52 Multiple Plots
06:08 Using Figure Objects
12:32 Subplots
15:03 Appearance Options
21:28 Saving Plots
22:09 Working with Pandas Dataframe
29:01 TeX Markup (Math Symbols)
36:41 Histograms
40:57 Bar Charts
48:19 Pie Charts
53:50 Timeseries
59:31 Tables
1:08:21 Scatterplots
1:12:59 3D Surfaces
1:21:38 Matplotlib Finance
1:26:23 Heatmaps
Probability in One Video : ruclips.net/video/sEte4hXEgJ8/видео.html
Statistics in One Video : ruclips.net/video/tcusIOfI_GM/видео.html
NumPy in One Video : ruclips.net/video/8Y0qQEh7dJg/видео.html
Pandas in One Video : ruclips.net/video/PcvsOaixUh8/видео.html
1:33:45
Stayed til the end.
Have an enormous project with a crazy learning curve ahead. I don’t plan on using matplotlib but I wanted to learn it before PlotLy to get a second perspective.
I was just finishing an implementation of a deep learning paper and needed to plot some stuff, great timing!
That's great! I'm happy I could help :)
The college professor you wished you had! To say Derek knows his stuff is just a bit understated. Video moves rapidly covering many visualization possibilities using Jupyter notebook. One of the hurdles I've had with Matplotlib is that there are actually too many possibilities with disjointed specifics. The pace, logical progression and scope of this video is perfect, leaving the viewer with functioning code examples to run, modify and explore on their own. Bravo!
Thank you for the nice compliment :) I do this stuff for a living so I’m happy to hear that I was able to make it understandable.
You are the only guy I have found who can really teach me data analysis. You are really good at this Derek. Thank you. Elijah Kalii. Nairobi, Kenya
I just realized I needed to learn matplotlib in DEPTH and of course it WOULD be Derek to help me, gotta love this freakin genius.
WOW , that was a really through class!!! I know that you din't dive too deep on every module, but it actually is not neeeded . anyone wanting to learn Python will find he's way, all we need is this headstart!!
OMG!! Everything I need in 1 video. Derek, you are my superhero!!! SMASHING the LIKE Button!!
Thank you very much :) I appreciate that!!!
Thank you and keep making these! I've watched hundreds of Python videos here in RUclips, but yours might be the best.
Really powerful introduction of Matplotlib from basic to really advanced level. This has helped me tremendously in my ML plotting.
This is a fantastic tutorial. Even though I have a lot of experience in plotting using Excel and PowerBI, for reasons unknown, I've always felt intimidated by the idea of plotting using python. From your video, I've gained a lot of knowledge and confidence, thank you so much for your effort. Also, many thanks for the ipynb file, much appreciated. Next stop - Seaborn Tutorial :-)
Thanks for taking the time to tell me it helped :) Enjoy Seaborn
Ty, the way you talk is really easy to understand for non-native English speakers like me
This is great, the info comes at you so fast... Basically you see what is possible then when you need to actually use it you come back and pause the video and copy the code :D
I just watched your Plotly and matplotlib tutorials, they are awesome, I' heading to watch the seaborn , numpy and and the other cool videos you have! Keep the great work, greetings from Mexico
Thank you very much :) I love Mexico!
By 12 minutes in, my mind was absolutely blown. Thank you for making these!
Thank you :) I'm very happy that I could help
This series has come up at a fantastic time in the Data Science / Machine Learning space. As a software engineer myself with weaker background in mathematics, trying to prepare for the future in this field has always been daunting. These video tutorials, along with the statistics series are extremely valuable to making this area more accessible & fun to learn - thank you @Derek Banas !
Thank you :) I’m doing my best to create a step-by-step course while also trying to present everything in new ways. I’ve been using data science for work for quite some time so I have my core toolset. I will however try to cover everything to the best of my ability. For example I mainly use PyTorch, but I’ll cover Tensorflow as well.
Commenting after watching the whole video and also following along on a Jupyter notebook of my own. Sincere gratitude to you!
Thank you for taking the time to say I helped :) I greatly appreciate it
Great video for starting off various charts...then do deep dive into specifics as needed using documentation. (Watched to the end!)
I just found your channel, and it has everything that i need, Thank you very much
Thank you :) I’m happy I could help
This video is invaluable. It is so well-prepared and every plot is explained very clearly.
Thank you for the nice compliment :) I'm happy you found it useful!
I watched the whole video but in two goes. As usual, very informative and professional. Thank you 🙂
Thanks so much for your tutorials, I am a big fan! Always watch all the way to the end!
Thank you for a great video. I did watch until the end and appreciate the great pacing.
Watched the whole video and followed along on Jupyter. Excellent content that deserves a like and subscribe
Thank you very much :) I'm very happy that you enjoyed it
Your teaching method is just great! I love the way you are teaching Sir. I recently purchased a Data Science course in Udemy from Jose Portilla, but his teaching method is not interesting to me at least. And I wanted to say that I rarely comment on videos on RUclips, and those are the ones I liked a lot like this video! Bravo!!!
Thank you very much :) I'm glad that I could help.
Just completed the whole video, above everything else just loved the way you say 'anndddddd' 😅
It's such an amazing course, thank u a lot. I'm so glad that I've found ur channel!
Thank you :) I'm very happy you found it useful!
stayed until the end and am now going to watch all of your other videos
Thank you very much :) There are a lot of them!
Great Content and very concise one. Really enjoyed learning plotting with Matplotlib. Keep up the good work.
Thanks for nice tutorial! Some shorthand for rounding in Tabels section:
df.iloc[:, 1:6] = round(df.iloc[:, 1:6], 2)
This line of code would round all values in all price columns
Tks for the video! You made it very easy and the cheat sheet will come in handy. Now I will move to the seaborn tutorial. Have a great day!
I'm happy I could help :)
Watched the whole video, although I skipped some details since I am quite familiar with matplotlib. I liked slower pace of the video, it made it easy to casually watch the video without my full attention.
I am looking forward to seaborn, which i have not used it yet, so you will have my full attention. Thank you very much for your videos, the amount and breadth of topics you are able to cover is amazing.
Thank you for the input. Yes I just slightly slowed the video to see if anyone noticed. I appreciate both that you watched the video and that you said you preferred the slower speed I'll keep doing it. Yes Seaborn is next. It should be up in less than 6 days.
Thank you very much for this amazing tutorial! Love from Germany
I'm very happy you found it useful :)
Amazing tutorial. was easy to follow. thanks Derek.
dude , 3D Surfaces are amazing
My first line of code worked at first try! \o/
Never trust computers
completed the whole thing amazing
Thanks to this video I finally understood how to modify axes properly (I need to create them in a figure first!) week of figuring it out paid off!
I'm happy I could help :)
@@derekbanas One questions, I have struggled to save the file, as it does not show the axes (and I noticed it does not show it in your video either) any thoughts on how to get the axes to show on the saved file?
Super useful. Incredible preparation and delivery. Love from Berlin ❤️
Thank you for the nice compliment :)
God will bless you for giving free education... Keep it up... ✌️♥️
If possible try to cover keras and tensorflow
Thank you for the nice message 😁 I tend to use PyTorch most often but I will definitely cover tensorflow and keras as well
@@derekbanas Thanks😊
Great series: numpy, pandas, matplotlib. what's next? tensorflow? pytorch? scikitlearn?
Thank you 😁 Yes I'll cover all of the above and more. Seaborn is next
@@derekbanas Wow!!
I am very ready for this one, thank you!
Thank you for following my series :)
Great video, Derek!!
love your content man.......much support to you!!!
Thank you very much :)
Great content! I learnt a lot
At 23:50, why do we need to convert the pandas dataframe to a numpy array. Isn't pandas based on numpy.
Also, many stackexchange posts suggest that .values (is this an attribute?) is not recommended to do this.
They suggest using the function Dataframe to numpy() instead.
At 38:10, why are you choosing stacked=True if there is only one data set for the histogram. Isn't this redundant (and kinda confusing)?
At 48:10, surely you need to change the tick labels back form the index to the school types again using xticks(ticks, labels) etc?
The syntax for subplotting is incredibly confusing. There are various functions e.g. subplot(), subplots(), add_subplot() or the axes() functions, all used in a variety of ways e.g. some as part of the module plt in plt.subplots() or plt.subplot() here and some as a method acting on the figure e.g. fig.add_subplots. Then there's the various and confusing indices for the arguments.
For example, around 5:15, couldn't you first just assign plt.subplot() with its arguments to a variable e.g. ax1 and then on the next line have ax1.plot() with it's arguments.
The reason I say this is that I can't understand how plt.plot() with its arguments knows how to work on the specific axis plt.subplot() etc on the line above it.
I suspect fig.add_subplots is the best way to create subplots, but every video seems to do it differently.
Surely at 11:50, the arguments for positioning the text for axes2 are based not on the centre of the figure being (0,0) as you say, but on the origin of axis 2 being (0,0). If you see where the text ends up, this is clear (around (0,40) relative to the axis 2 origin).
Good video thanks.
I will watch it again.
Thank you :)
Fantastic tutorial. Thank you.
Excellent content and very useful stuff..all in one video..thx a lot for sharing Derek
Thank you very much :) Happy I could help
Thank you for this.
At 12:20, is there any good reason why the add_axes() method takes a list as argument, yet the text() method takes a tuple. It seems totally arbitrary since the arguments are both related to location etc.
Loved this video. Thank you so much.
Great tutorial, thanks.
That was an excellent tutorial. I did not understand why you used list comprehension at 41:18 instead of directly passing t_type as an argument?
Just finished it. thanks
Happy I could help :)
😊 very nice tutorial
Thank you very much :)
thank you for making this video, it really helped me a lot!
I'm very happy that I could help :)
Thank you very much for the wonderful vide0 :)
Thank you :) I'm very happy you enjoyed it
At 7:20 , I can't get this code to run: `fig1 = plt.figure(figsize(5,4),dpi =100)`
Error: NameError Traceback (most recent call last)
Input In [7], in ()
----> 1 fig1 = plt.figure(figsize(5,4),dpi =100)
Any idea what I have wrong here?
Chatgpt solved it: fig1 = plt.figure(figsize=(5,4),dpi=100) Explanation below ->
'The issue with your code is that you have specified the figsize argument incorrectly. The figsize argument expects a tuple of width and height values, but in your code, you have specified it as two separate values. To fix this issue, you can modify your code as follows:
import matplotlib.pyplot as plt
fig1 = plt.figure(figsize=(5,4), dpi=100)
axes_1 = fig1.add_axes([0.1, 0.1, 0.9, 0.9])
axes_1.set_xlabel("x-axis label")
plt.show()
Thanks chatpgt
Also just saw you correct the error @ 9:30 lol.....
8:44 will anyone please tell me how you wrote the small 2 like that
Great video, as always! Btw, first.
Thank you very much :)
top-notch tutorial as always. Thank you so much, man. You are my motivation that keeps me productive every day. BTW, I just noticed that your typing speed is getting slow. But I still like your content tho.
Thank you very much :) I have been messing with the tutorial speed to see if people like videos that are slightly slower.
@@derekbanas Alright. I can see some data science projects over there...(I just travelled into the future).LOL
5:15, Hi what does 1,2,1 refer to exactly in this instance?
fajtastic review!!
super easy to undestend:)
Thank you very much 😁
Thanks for the valuable piece of information. Appreciate that :)
I'm happy to be of help :)
@@derekbanas big thanks sir
Hi Derek, good job. How did you input x^2 in your Jupyter notebook at 8:43?
You mean how to input the "²"? ctrl + alt + 2 (not the 2 on the numpad, the other one)
Wow, thank you so much for this!
Thank you for following my videos :)
Make a video on OpenCV please!
Hey Derek you are amazing I have learnt a lot from your machine series if possible can make a video on sikit learn
And machine learning algorithms in python with real-time examples that would be great!!
Again, thanks a lot for your effort it really makes a difference load of love from india..
Thank you very much :) Yes I plan to do both and a whole lot more. Seaborn is next
Thank you, this was great!
Thank you for taking the time to say it helped :)
WAITING FOR THIS FOR SOO LONG
I hope you find it useful :)
Can anyone help me in adding labels for the scatterplot sample? I'm trying but it keeps getting errors.. the scatterplot is in 1:12:00
plt.scatter()
plt.plot()
plt.title()
plt.xlabel()
plt.ylabel()
plt.show()
plt is a module and all these scatter,plot,show are functions than how are they connected like where is the information from one function being stored so that another function can use it??
please answer me
A ton of mercis
je suis très heureux d'aider
in the timeseries section it shows the error that ValueError: x and y must have same first dimension, but have shapes (64,) and (251,)
even after copying your code it does not seem to work What do you think might be the issue here im kinda stuck thanks
Hi derek, I learned alot from you. (Thank you ) **1000
Thank you for taking the time to tell me that :) I appreciate it
I have favour to ask you bro ,
Will Go deep into Descriptive Analytics along with Supervised Machine Learning?
I don't get anything which My Teacher teaches and they don't put much effort in teaching us(that's sorry to say but it's true).
And one thing I really like your "Machine Learning and Data Science " series and I know that there are more things to come in that series .
So best of luck and i really hope that you will go as deeper as possible in this series .Best wishes with you Bro . Keep it up 👍👍💪
Thank you for the nice message :) Yes I have promised I will dedicate myself to data science, machine learning and the related maths for the rest of the year. My goal to to provide a complete learning path all at one location in order.
Would you ever consider doing a Dafny tutorial? I've have a very short introduction to it in one of my uni classes and thought it was interesting, and I'm sure it would help some people!
I'll see what I can do. I have looked at it and it is very verbose indeed
@@derekbanas Thanks! I really appreciate your work :)
It would be great if you take some time and explain the installation procedure and troubleshooting at the beginning. I am using pip install, matplotlib is installed but it is showing error in import.
In the description I have installation videos for Windows and MacOS. What error are you seeing?
Thanks for another great video.
It's probably me but I could not find the link to jupiter notebook you used in the video to run the examples. Could you please point me in the right direction if it is possible?
Thank you :) I show how to install everything for Windows here : ruclips.net/video/a7Ylbn1ikF0/видео.html and for Mac here which is basically the same for Linux ruclips.net/video/2JeoNlCcLOM/видео.html and at the end of my Pandas tutorial I talk about setting up virtual environments and installing libraries ruclips.net/video/PcvsOaixUh8/видео.html
Sorry everything is all over the place. That is sort of the problem with trying to create a big course, while also making these learn in one videos.
@@derekbanas Thanks Derek for getting back to me. The video that you mentioned has a link to the Python codes that you used for the stats tutorial, but no codes for Matplotlib video that I am after. I found these on your web site www. newthinktank. com/2020/08/learn-matplotlib-one-video/ (remove spaces) where there was a link to your Github. Thanks again
many thanks
I'm happy to help
Thank you!
I'm happy you found it useful :)
sir, How do you wrote a supersript x**2 casually in jupyter notebbok in code mode?! :O
Please do the Digital humanities introduction video(s).
I'll look into it. Thank you for the request
How did you I will come to your page to find machine learning tutorials these days to upload these?! Thanks, I have never come back from your channel with absence.
Thank you 😁 I hope you find them useful
Thanks man!
Happy to be of help :)
Thanks again for this great course! Could you show me your solution on Subplout IN[12] with a for loop?
Hey, thanks for the video, it's so well explained. For the Time Series section, I downloaded data from 21 Aug 2019 - 21 Aug 2020. I've done all the same code but when I put in plt.plot (date_arr_np, goog_cp) I get an error and this message: 'x and y must have same first dimension, but have shapes (64,) and (253,)'. Do you know what's gone wrong or how I can fix this?
Thank you :) It is hard to say. I have all the code and the csv file here github.com/derekbanas/matplotlib Try it and make sure you don't get an error
@@derekbanas Same problem here, I managed to fix this example with your data, but in case of data I downloaded, it didn't work. Did you swith some other options on yahoo or something else? Anyway, thank you for your great work!
So I figured it out! Almost kids' joy here :) My solution was to extract the same amount of rows from downloaded material a then use it. It may not be the most elegant sulution, but it worked.
goog_data = pd.read_csv('GOOG.csv')
goog_data
goog_data_np = goog_data.to_numpy()
goog_cp = goog_data_np[:, 4]
data = pd.DataFrame(goog_cp)
rows = data.head(43).to_numpy()
#odstranit svátky
holidays = [datetime.datetime(2022, 11, 17), datetime.datetime(2022, 10, 28)]
date_arr = pd.bdate_range(start='10/1/2022', end='12/4/22', freq='C', holidays=holidays)
date_arr_np = date_arr.to_numpy()
fig_7 = plt.figure(figsize=(8,5))
axes_7 = fig_7.add_axes([0.1, 0.1, 0.9, 0.9])
plt.plot(date_arr_np, rows)
thanx Derek
Thank you very much :) Happy I could help
Why is pandas, sometimes, but not always used in conjunction with matplotlib?
Any suggestions on how to read/parse/plot a string from the (py)serial port, such that no data is dropped? The transmitter sends lines like "1.23, 3.3, 87.1
" every 500ms for approximately 2 minutes..
yet in the code below, the update to the plot seems to take too much time, because the data starts to get dropped (or gets backed up into a queue?), and does not get plotted nor csv saved . Is there more efficient way of plotting (animation) or using threads
import serial
import time
import csv
import threading
import numpy as np
import matplotlib
matplotlib.use("tkAgg")
import matplotlib.pyplot as plt
#TODO : Use threads for Plot and Serial.. like ComPlotter or felipengeletrica /PyDatalogger
ser = serial.Serial('/dev/ttyACM0')
ser.flushInput()
plot_window = 20
y_var = np.array(np.zeros([plot_window]))
plt.ion()
fig, ax = plt.subplots()
line, = ax.plot(y_var)
while True:
try:
ser_bytes = ser.readline()
try:
decoded_bytes = float(ser_bytes[0:len(ser_bytes)-2].decode("utf-8"))
print(decoded_bytes)
except:
continue
with open("test_data.csv","a") as f:
writer = csv.writer(f,delimiter=",")
writer.writerow([time.time(),decoded_bytes])
y_var = np.append(y_var,decoded_bytes)
y_var = y_var[1:plot_window+1]
line.set_ydata(y_var)
ax.relim()
ax.autoscale_view()
fig.canvas.draw()
fig.canvas.flush_events()
except:
print("Keyboard Interrupt")
break
##################################
##################################
##################################
def Main():
ser = None # serial.Serial(3, 11520)
t1 = threading.Thread(target = Task1, args=[ser])
t2 = threading.Thread(target = Task2, args=[ser])
Report("Starting Thread 1")
t1.start()
time.sleep(3)
Report("Starting Thread 2")
t2.start()
if __name__ == '__main__':
Main()
##################################
##################################
##################################
import serial
import wx
import numpy
import matplotlib
matplotlib.use('WXAgg')
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg
from matplotlib.figure import Figure
import matplotlib.pyplot as plt
class DataLoggerWindow(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, -1, "ComPlotter", (100,100), (640,480))
self.SetBackgroundColour('#ece9d8')
# Flag variables
self.isLogging = False
# Create data buffers
self.N = 100
self.n = range(self.N)
self.M = 3
self.x = []
for m in range(self.M):
self.x.append(0 * numpy.ones(self.N, numpy.int))
# Create plot area and axes
self.fig = Figure(facecolor='#ece9d8')
self.canvas = FigureCanvasWxAgg(self, -1, self.fig)
self.canvas.SetPosition((0,0))
self.canvas.SetSize((640,320))
self.ax = self.fig.add_axes([0.08,0.1,0.86,0.8])
self.ax.autoscale(False)
self.ax.set_xlim(0, 99)
self.ax.set_ylim(-100, 1100)
for m in range(self.M):
self.ax.plot(self.n,self.x[m])
# Create text box for event logging
self.log_text = wx.TextCtrl(
self, -1, pos=(140,320), size=(465,100),
style=wx.TE_MULTILINE)
self.log_text.SetFont(
wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.NORMAL, False))
# Create timer to read incoming data and scroll plot
self.timer = wx.Timer(self)
self.Bind(wx.EVT_TIMER, self.GetSample, self.timer)
# Create start/stop button
self.start_stop_button = wx.Button(
self, label="Start", pos=(25,320), size=(100,100))
self.start_stop_button.SetFont(
wx.Font(14, wx.DEFAULT, wx.NORMAL, wx.NORMAL, False))
self.start_stop_button.Bind(
wx.EVT_BUTTON, self.onStartStopButton)
def GetSample(self, event=None):
# Get a line of text from the serial port
sample_string = self.ser.readline()
# Add the line to the log text box
self.log_text.AppendText(sample_string)
# If the line is the right length, parse it
if len(sample_string) == 15:
sample_string = sample_string[0:-1]
sample_values = sample_string.split()
for m in range(self.M):
# get one value from sample
value = int(sample_values[m])
self.x[m][0:99] = self.x[m][1:]
self.x[m][99] = value
# Update plot
self.ax.cla()
self.ax.autoscale(False)
self.ax.set_xlim(0, self.N - 1)
self.ax.set_ylim(-100, 1100)
for m in range(self.M):
self.ax.plot(self.n, self.x[m])
self.canvas.draw()
def onStartStopButton(self, event):
if not self.isLogging:
self.isLogging = True
self.ser = serial.Serial()
self.ser.baudrate = 38400
self.ser.timeout=0.25
# Try serial ports one by one starting
# with COM30 and working downwards
for m in range(29, 0, -1):
self.ser.port = m
try:
# Try this port number
self.ser.open()
# We only get to here if port opened
self.log_text.AppendText(
'Opened COM' + str(m+1) + '...
')
break
except:
# We end up here if this port number
# failed to open
pass
if self.ser.isOpen():
# We successfully opened a port, so start
# a timer to read incoming data
self.timer.Start(100)
self.start_stop_button.SetLabel("Stop")
else:
self.timer.Stop()
self.ser.close()
self.isLogging = False
self.start_stop_button.SetLabel("Start")
if __name__ == '__main__':
app = wx.PySimpleApp()
window = DataLoggerWindow()
window.Show()
app.MainLoop()
How did he put superscript (square) in string? Please somebody tell me.
Thanks :)
What is the benefit of np.arrange i did not get it.😭
where is the x, y_axis when saving the figure to a file?
Increase the figure size and both will show in the file
Can you give the serial, where to start this series from pandas/numpy/statistics. That will be very helpful for me.
Here is my Data Science & Machine Learning Playlist in order ruclips.net/p/PLGLfVvz_LVvQy4mkmEvtFwZGg1S38MUmn
Very good tutorial
How about tutorial on geogabra py api
geogabra is the best
Thank you :) That is funny. I was looking at how I could use GeoGebra in my math courses just the other day. I'll definitely be using it soon.
@@derekbanas it has it's own script language and api for other languages, also he has gui buttons and other staff.
Classic is the full package including 3d 2d statistic and other staff.
Hi Derek sir do you know any online compiler for machine learning if you Know then tell me
Sorry, but machine learning requires a pretty powerful computer. I used to use AWS which is pretty cheap up to a point.
@@derekbanas ok thanks
Nice tutorial, next video on PyQtGraph please ?
I'll see what I can do. Seaborn is next because I'm already working on it. I have to schedule out way in advance to make videos every day.
Derek Banas thanks. Looking forward for the next videos. I found PyQtGraph visualisation to be faster than matplotlib especially for real time data/signals and at the same time, PyQtGraph is difficult to understand(for me :P)
I'll definitely check it out 😁 Thank you for the request
Can you please cover a series on PyQt5 with Designer (Qt)?
I'll see what I can do
@@derekbanas Hope to see a detailed series!🤞
@Derek Banas hey derek ive watched your java tutorial and i wanna be java backend programmer what should i learn after that i mean what concept should i learn first on java ee and actually u promise me to create Spring tutorial ?
Basically everything listed in the certification is required education.oracle.com/oracle-certified-professional-java-ee-7-application-developer/trackp_900
@@derekbanas i saw that but its little a bit counfusing u know could u cover it next tutorial i know u already created a java ee but its not enough i gues can u cover java ee i really need this and o already asked u to cover Spring too if u cover these topics your gonna change my life Thanks bro
How did you produce the superscript while typing x/x^2 for the legend?
Look for the TeX part of this tutorial