Matplotlib Crash Course
HTML-код
- Опубликовано: 16 ноя 2024
- Learn the basics of Matplotlib in this crash course tutorial. Matplotlib is an amazing data visualization library for Python. You will also learn how to apply Matplotlib to real-world problems.
✏️ This course was created by Keith Galli. Check out his RUclips channel: / @keithgalli
🔗 Source Code: github.com/Kei...
🔗 Matplotlib Pyplot Documentation: matplotlib.org...
🔗 Font List: jonathansoma.co...
🔗 Matplotlib Style Options: matplotlib.org...
🔗 Kaggle Data Link: www.kaggle.com...
Install libraries Needed for this video:
Option 1:
Open up a terminal window and type
pip install matplotlib
pip install numpy
pip install pandas
Option 2:
Download anaconda which will contain all the packages we need. A video on how to do this is here: • Python Tutorial: Anaco...
--
Learn to code for free and get a developer job: www.freecodeca...
Read hundreds of articles on programming: freecodecamp.o...
"Let's just jump into it" = immediate upvote
Philly D :)
Why you called it upvote man 😭😭😭 now I think your a neck beard
The best thing about this tutorial is that he keeps the mistakes made.
*My takeaways:*
*1. Line chart* 2:11
1.1 Potting a line chart using *plot* and *show* 3:27
1.2 Adding a title using *title* 5:21
1.3 Adding labels to x and y axes using *xlabel* and *ylabel* 6:24
1.4 Changing the font of title and labels. Resizing title and labels using *fontdict* 7:02
1.4 Editing tick marks using *xticks* and *yticks* 8:50
1.5 Adding a legend using *legend* 11:04
1.6 Changing line style by passing parameters to *plot* 12:14
1.7 Adding a 2nd line 17:33
1.8 Resizing a chart using *figure(figsize(), dpi=)* 21:55
1.9 Saving a chart using *savefig* 24:34
*2. Bar chart* 26:48
2.1 Potting a bar chart using *bar* and *show* 27:40. The size of a bar chart can be changed using *figure(figsize(), dpi=)* as well
2.2 Setting bar patterns using *set_hatch* 28:50
*3. Real world Matplotlib examples* 31:10
3.1 Example 1 - line chart 34:36. Input .csv data file using *pandas pd.read_csv()*
3.2 Example 2 - histogram 52:35. Potting a histogram using *hist* and *show* . Setting bins.
3.3 Example 3 - pie chart 1:00:08. Potting a pie chart using *pie* and *show* . Looking for a condition in the data using *pandas loc* . Adding labels for pie chart using a list. Changing colour. Show percentage using *autopct*
3.4 Example 4 - another pie chart 1:07:20. Converting string data to integer data using *strip* . Changing the pie chart style using *style.use* . Using *pctdistance* to define the positions of percentage. Using *explode* to split the pie chart.
3.5 Example 5 - box plot 1:18:33. Potting a box plot using *boxplot* and *show* . Using *set* to set colour and linewidth
Lei Xun Thanks for sharing
Thanks
@@aarushgoyal You are welcome
Super helpful !! Thank you for this :)
@@awesomekalyana15 You are welcome!
Much better than lots of those paid courses out there! Lean, clean and straightforward! Thanks a lot and please please record more videos on other data Science and python related topics in the same manner you did this course!
That guy is an MIT graduate hahaha
real talk
i cant believe this is free of charge......thank you so much!!!!!!!!!!!!!!!!! i have also watched your numpy and pandas tutorials and enjoyed them very much!!! thank you for doing this, you are making such a difference.
I think keeping documentation window open was such a great advice. My struggles with matplotlib have gone down once I Put that tip in practice.
plt.figure(figsize = (12,7))
for c in gas.columns[1:]:
plt.plot(gas['Year'] , gas[c] , label=c , marker='.')
plt.legend()
plt.show()
This worked for me while plotting the line graph for all countries!
(Note : Include the import statements and read the csv first, haven't included that here.)
Thank you for the tutorial! This channel is basically where I have started picking up things.
I can easily tell that Keith is very keen on FUT and probably has like the best Ultimate team in FIFA 21 ahahahha. Really enjoyed your course, very coherent and simple. Thank you!
I usually dont comment but today your course has made me comment, Really it was a very good course learned a lot. KEEP IT UP DON'T STOP!!!!!!!!!!!!!!!!!!!!!!!!!!
Python contour animation
ruclips.net/video/ZFQwwxyKG_U/видео.html
Wow ! It's a superb course ! I learnt tons of things ! Also, at 59:00, you can use log=True option to make y log scale
You're doing great ! Carry on !
Thank you, Highly appreciate... most important thing is, this is free for every one.. this course much better than paid courses...
Okay, it took me a lot of time to complete numpy, pandas and matplotlib from you keith, but I think it was worth it. Although, I remember NULL.
For the people who are following this in 2024, and not getting the country names automatically after using for loop
just add label=country in plot arguments like this:
for country in gas:
if country != 'Year':
plt.plot(gas.Year, gas[country], label=country)
Great teacher you are man. I have watched all your data visualization videos they all are amazing...
Very quick, clear and concise highly recommended
at min 4:34 you can just write plt.plot(x,y); instead of plt.show() ; is enough, thanks for tutorial
Thank you very much for your wonderful teaching and real-world example. Nice course for learning.
40:00 why this code worked is hilarious
Thank you so much for your great tutorials. Can you do a tutorial on tableau please?
8:22 🤪
Anyways, thanks for making the tutorial. It's a very helpful tutorial for us 😁
lol
t and k are so far apart in the alphabet 🤨
Great introductory course to Matplotlib.
thanks for amazing explanation. sir please make a video on Scipy.
exactly what I was about to start. Thank you.
A very beautiful representation of Matplotlib
Galli is such a dope dude. thanks.
More MatPlotLib courses!
Thanks a lot Keith, very crisp explanation!
You did a really good job on this. I like how you motivate what you're showing. Great stuff.
This was very useful, thank you!
4:11 alternatively you can also use plt.plot(); # use ; to not make to show that matplotlib object creation at certain memory location.
i wish Coursera courses were this short and brief.
brilliant tutorial
😍😍😍 will you make a video for pandas and numpy too? 👀
Try this one: ruclips.net/video/r-uOLxNrNk8/видео.html
I learnt pandas with this guy #respect
Great tutorial
Thank you so much for your great tutorials.
40:15 'How it worked' 🤣🤣. Sometimes we coders don't know what actually happened but that finally works
yeah bro even i got error for that🤣
Very well explained! Thank you very much! 💛
Thank you Keith :)
i really like your course keep it up sir
Thanks Keith
Yoooooo..... waiting for such a course
thanks for this beautiful video love from india
Great video - nice one. Thanks.
excellent as always.
Awesome!!! TQVM!!
this is gold !
Could you go through the iplot function from matplotlib, too (it’s basically a plotting function that makes interactive plots) and go through candle stick plots? (iplot plots 3d as well as 2d, so please go over iplot 3d as well iplot 2d if you can)
thank you so much man .much appreciated
this guy very good
thanks man, very throroughly !
8:20 What was that bro?
Nice explanation. Can you please tell me what that for loop is doing and how it will identify the country in gas?
Hi I asked a similar question. I think it's because the for loop iterates over the headings (the countries) of the CSV file (so countries in the code "for countries in" will refer to these headings). It iterates over these headings (and not over the rows of the table) since the headings are the keys of the dictionary-like structure gas. That's my understanding.
Love your videos they help me a lot.
Nice one and keep it up!
So Good
good stuff
Nice!
My G!!!
Thanks pal
Thanks a lot!
Amazing Thanks a lot
i was waiting for this video ..... anyway can i use Pycharm ?
Well it's really late but if you still dont know yes
no if using for datascience purpose
Thanks a lot
Thank you
Can you kindly post a link to your Pandas crash course video? Thank you.
I was floored by that yel joke. Hahaha
great vid
Thanks🤩
26:30, let one rip eh?
Please make a video on matplotlib animations...
How to comment three lines together? Check 30:16
Nice
Phyton trorial about data sciences on data backup
At 45:40, with the for loop, why does it automatically iterate over the headings and not the values under those headings. Is it because pandas saves the CSV file as a dictionary-like structure with the headings as keys. And these are automatically iterated over in a for loop?
At 1:12:00, how do you not get an error when the condition checks if the entry is less than an integer, when not all of the values under the heading weight will have been converted to integers in the previous code (ie the code "else x" doesn't necessarily give an integer in the list comprehension).
At 1:22:10, why aren't the arguments for the boxplot barcelona[1] and madrid[1] rather than barcelona and madrid. Since barcelona and madrid seem to be 2D arrays and not 1D arrays.
Could you have iterated through the countries using gas.columns[1:] ?
Yes Sir
If you were to read a binary file containing sample points,
file = open("sample.bin", "rb")
How could you import the data into an array, for plotting? For example, assuming you prompt the user for filename, the number of bytes per data, and the endiness.. i.e. the first byte is the MSB or LSB... how would you load/plot the array, data value on the y, and sample number on the x?
I thought the bar trick with around 30:00 is really cool. The One for the for loop. However, I `m not sure what the "pop" functionality is . Does anyone knows?
pop(0) chooses the first element in the list and removes it from the list. So the next first element after '/' is removed will be 'o'. If this explanation is unclear, do let me know.
quick question, do you need to know numpy and pandas to learn matplotlib?
How about a 4D plot with matplotlib?
If there is any Indian. Better you prepare for government jobs. They give good perks and allowances as compared to FAANG!
@Rahul Ranjan then leave it! Government job is best👍
@@devbhatia7107 okay go prepare for govt job while sitting idle at home for 5 years :)
💕💕💕💕💕
1:00:00 How do I use the bar_label function to this histogram? I always the error "AttributeError: 'tuple' object has no attribute 'patches'"
46:30
for country in gas:
if country != 'Year':
plt.plot(gas.Year, gas[country], marker ='.')
how did you manage to put labels for each country?
Ps. throws error that says 'No handles with labels found to put in legend.'
plt.plot(gas.Year, gas[country], label=country, marker=".")
then outside the loop: plt.legend()
@@nikhiljagtap1669 thank you
0:09:57 ohhhhh my goshhhh!!!!!! XD
Hi, sorry to be a pain, but when I try to import Matplotlib, it gives me an error, DLL load failed while importing ft2font
Can someone pls help me.
Edit: is there any fix?
pip install matplotlib or download anaconda that way you don't have install matplotlib.
Hi! I've been trying to follow your steps but I got an error, I wonder if it is due to the Phyton or matplotlib version:
countries_to_analyze=['Mexico','USA','Canada','Japan']
for country in gas:
if country in countries_to_analyze:
plt.plot(gas.Year,gas[country], marker='.',label=country)
plt.xticks(gas.Year[::3])
plt.legend()
plt.show()
TypeError Traceback (most recent call last)
Cell In[131], line 6
3 if country in countries_to_analyze:
4 plt.plot(gas.Year,gas[country], marker='.',label=country)
----> 6 plt.xticks(gas.Year[::3])
7 plt.legend()
8 plt.show()
TypeError: 'list' object is not callable
Any help would be so appreciated, take care, Jesus
Is matplotlib an engineering programm cause am studying electrical engineering though ......?????
please share your panadas video link also ,i am not able to find it
Can anyone share the official documentation link here
"aaaahhh"
can someone recommend to me a good video for 3D and higher dimensional graphs
For anyone watching this in 2024, careful, as MatPlotLib has changed a few things and deprecated some of the functions/methods in this video.
Peace to all, at the moment I am making a web-based item lending form, which I want to ask how is it so that when inputing time is not conflicting, for example: If person A enters the form "will" borrow goods from 02:00 - 03:00 , then person B cannot input the loan form with the same item between the hours of 2:00 to 3:00. how to avoid conflicts in the database.
In the first example 46:45 i am not able to get the legend when for loop is run. Can someone please help me with that
Please do one numpy tutorial too 👍👍👍
Numpy course: ruclips.net/video/QUT1VHiLmmI/видео.html
@@freecodecamp omg you are the best guys
33:05 more more
I want to read the fifa_data.csv with pd. read....... But it shows me errors like '' no such file or directory: 'fifa_data.csv'. I downloaded pandas.
I don't know what to do. Please somebody could help me?
I've found a tutorial on RUclips for the problem.
I have a question please ... Do I need to learn numpy or pandas before I can start freelancing with matplotlib ?
Yes, They are inter-related
40:29 matplotlib showed no handles with labels found to put in legend? can anyone tell me why it is not working
just put label='country_name' argument in every plot function then use legend function