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...

Комментарии • 169

  • @Ricocase
    @Ricocase 4 года назад +209

    "Let's just jump into it" = immediate upvote

  • @d.youtubr
    @d.youtubr 2 месяца назад +8

    The best thing about this tutorial is that he keeps the mistakes made.

  • @leixun
    @leixun 4 года назад +320

    *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

    • @Amy_Yu2023
      @Amy_Yu2023 4 года назад +2

      Lei Xun Thanks for sharing

    • @aarushgoyal
      @aarushgoyal 4 года назад +1

      Thanks

    • @leixun
      @leixun 4 года назад +1

      @@aarushgoyal You are welcome

    • @awesomekalyana15
      @awesomekalyana15 3 года назад +1

      Super helpful !! Thank you for this :)

    • @leixun
      @leixun 3 года назад +1

      @@awesomekalyana15 You are welcome!

  • @MrVovik007
    @MrVovik007 4 года назад +73

    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!

  • @softyo
    @softyo 2 года назад +14

    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.

  • @saurabhsamdani
    @saurabhsamdani 2 года назад +17

    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.

  • @rishabhmediratta6200
    @rishabhmediratta6200 3 года назад +10

    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.

  • @nikitaizmaylov4888
    @nikitaizmaylov4888 3 года назад +8

    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!

  • @YashPatil-iq1yw
    @YashPatil-iq1yw 2 года назад +4

    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!!!!!!!!!!!!!!!!!!!!!!!!!!

    • @Structural_analysis
      @Structural_analysis Год назад

      Python contour animation
      ruclips.net/video/ZFQwwxyKG_U/видео.html

  • @pi_r_mlm
    @pi_r_mlm 4 года назад +20

    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 !

  • @dhanushkamadhusanka683
    @dhanushkamadhusanka683 2 года назад +1

    Thank you, Highly appreciate... most important thing is, this is free for every one.. this course much better than paid courses...

  • @shashankgsharma
    @shashankgsharma Год назад +1

    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.

  • @Aman-yu4re
    @Aman-yu4re 5 месяцев назад

    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)

  • @yudhisthirsingh8401
    @yudhisthirsingh8401 4 года назад +7

    Great teacher you are man. I have watched all your data visualization videos they all are amazing...

  • @jameshuang582
    @jameshuang582 3 года назад +1

    Very quick, clear and concise highly recommended

  • @AdoiyAngV
    @AdoiyAngV Год назад

    at min 4:34 you can just write plt.plot(x,y); instead of plt.show() ; is enough, thanks for tutorial

  • @RabiulIslam-tw6qc
    @RabiulIslam-tw6qc 2 года назад +1

    Thank you very much for your wonderful teaching and real-world example. Nice course for learning.

  • @saketkumar1123
    @saketkumar1123 5 месяцев назад +3

    40:00 why this code worked is hilarious

  • @anmolmaitra78
    @anmolmaitra78 3 года назад +7

    Thank you so much for your great tutorials. Can you do a tutorial on tableau please?

  • @masadamsahid
    @masadamsahid 3 года назад +25

    8:22 🤪
    Anyways, thanks for making the tutorial. It's a very helpful tutorial for us 😁

  • @CodyBanks10
    @CodyBanks10 3 года назад +1

    Great introductory course to Matplotlib.

  • @codewithnotes8832
    @codewithnotes8832 3 года назад +2

    thanks for amazing explanation. sir please make a video on Scipy.

  • @RahulSingh-il6sz
    @RahulSingh-il6sz 4 года назад +2

    exactly what I was about to start. Thank you.

  • @ClassDu-lt6xy
    @ClassDu-lt6xy 3 месяца назад

    A very beautiful representation of Matplotlib

  • @AmitYadav-mk8dl
    @AmitYadav-mk8dl 6 месяцев назад

    Galli is such a dope dude. thanks.

  • @micha9926
    @micha9926 4 года назад +1

    More MatPlotLib courses!

  • @adithyavikramrajgaroju9218
    @adithyavikramrajgaroju9218 2 года назад

    Thanks a lot Keith, very crisp explanation!

  • @markkennedy9767
    @markkennedy9767 Год назад

    You did a really good job on this. I like how you motivate what you're showing. Great stuff.

  • @salambostaji9315
    @salambostaji9315 Месяц назад

    This was very useful, thank you!

  • @pawansapkota3970
    @pawansapkota3970 3 года назад

    4:11 alternatively you can also use plt.plot(); # use ; to not make to show that matplotlib object creation at certain memory location.

  • @rayyanamir8560
    @rayyanamir8560 3 года назад

    i wish Coursera courses were this short and brief.

  • @catbook628
    @catbook628 2 месяца назад

    brilliant tutorial

  • @ajefersonstiv
    @ajefersonstiv 4 года назад +4

    😍😍😍 will you make a video for pandas and numpy too? 👀

    • @freecodecamp
      @freecodecamp  4 года назад +2

      Try this one: ruclips.net/video/r-uOLxNrNk8/видео.html

  • @pythonfamily
    @pythonfamily Год назад

    I learnt pandas with this guy #respect

  • @easternteasers1127
    @easternteasers1127 4 года назад +2

    Great tutorial

  • @upgraduate
    @upgraduate 3 года назад +1

    Thank you so much for your great tutorials.

  • @devgupta2040
    @devgupta2040 2 года назад +2

    40:15 'How it worked' 🤣🤣. Sometimes we coders don't know what actually happened but that finally works

    • @suraj.panddey
      @suraj.panddey 10 месяцев назад

      yeah bro even i got error for that🤣

  • @kostiantynkarzhanov9216
    @kostiantynkarzhanov9216 Год назад

    Very well explained! Thank you very much! 💛

  • @saikoushik4064
    @saikoushik4064 Год назад

    Thank you Keith :)

  • @MuhammadHamza-ki3ze
    @MuhammadHamza-ki3ze 3 года назад +1

    i really like your course keep it up sir

  • @mahmudhasankhan7951
    @mahmudhasankhan7951 2 года назад

    Thanks Keith

  • @NareshKumar-dw9xp
    @NareshKumar-dw9xp 4 года назад

    Yoooooo..... waiting for such a course

  • @lakeshkumar1281
    @lakeshkumar1281 2 года назад

    thanks for this beautiful video love from india

  • @sachinthakkar4131
    @sachinthakkar4131 Год назад

    Great video - nice one. Thanks.

  • @mehdismaeili3743
    @mehdismaeili3743 Год назад

    excellent as always.

  • @digigoliath
    @digigoliath 3 года назад

    Awesome!!! TQVM!!

  • @frenchfries6386
    @frenchfries6386 2 года назад

    this is gold !

  • @blackwhite1257
    @blackwhite1257 5 месяцев назад +1

    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)

  • @bhanutejachittabathini19
    @bhanutejachittabathini19 4 года назад

    thank you so much man .much appreciated

  • @Maria-yx4se
    @Maria-yx4se Год назад

    this guy very good

  • @oswevega2939
    @oswevega2939 2 года назад

    thanks man, very throroughly !

  • @Dan-dg2pc
    @Dan-dg2pc 4 года назад +8

    8:20 What was that bro?

  • @mohammedjashim7186
    @mohammedjashim7186 Год назад

    Nice explanation. Can you please tell me what that for loop is doing and how it will identify the country in gas?

    • @markkennedy9767
      @markkennedy9767 Год назад

      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.

  • @browens3717
    @browens3717 4 года назад +2

    Love your videos they help me a lot.

  • @hermanmokgope3011
    @hermanmokgope3011 2 года назад

    Nice one and keep it up!

  • @JohnLyon0611
    @JohnLyon0611 Год назад

    So Good

  • @samyakbharsakle
    @samyakbharsakle 5 месяцев назад

    good stuff

  • @eiplou4116
    @eiplou4116 3 года назад

    Nice!

  • @jumpropemonk7703
    @jumpropemonk7703 4 года назад

    My G!!!
    Thanks pal

  • @max-burd
    @max-burd 3 года назад

    Thanks a lot!

  • @jacob_dmn
    @jacob_dmn 3 года назад

    Amazing Thanks a lot

  • @markbaidoo7325
    @markbaidoo7325 4 года назад +1

    i was waiting for this video ..... anyway can i use Pycharm ?

  • @ayushgupta1881
    @ayushgupta1881 11 месяцев назад

    Thanks a lot

  • @kkuku7471
    @kkuku7471 4 года назад

    Thank you

  • @at7828
    @at7828 5 месяцев назад

    Can you kindly post a link to your Pandas crash course video? Thank you.

  • @marbertpinque1512
    @marbertpinque1512 10 месяцев назад

    I was floored by that yel joke. Hahaha

  • @andile3982
    @andile3982 7 месяцев назад

    great vid

  • @ShivaniKumari-cj8nw
    @ShivaniKumari-cj8nw 4 года назад

    Thanks🤩

  • @smoothbeak
    @smoothbeak 4 года назад +5

    26:30, let one rip eh?

  • @Idontlikeitstilliamwatching
    @Idontlikeitstilliamwatching 4 года назад

    Please make a video on matplotlib animations...

  • @lbars
    @lbars 3 года назад

    How to comment three lines together? Check 30:16

  • @LLL124Original
    @LLL124Original 4 года назад

    Nice

  • @Harikrishna-py6rn
    @Harikrishna-py6rn 4 года назад

    Phyton trorial about data sciences on data backup

  • @markkennedy9767
    @markkennedy9767 Год назад

    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.

  • @tzviblonder8494
    @tzviblonder8494 3 года назад +1

    Could you have iterated through the countries using gas.columns[1:] ?

  • @bennguyen1313
    @bennguyen1313 4 года назад

    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?

  • @jumpropemonk7703
    @jumpropemonk7703 4 года назад +1

    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?

    • @rssaiganesh
      @rssaiganesh 4 года назад +2

      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.

  • @pa32779
    @pa32779 2 года назад

    quick question, do you need to know numpy and pandas to learn matplotlib?

  • @victormensah6448
    @victormensah6448 4 года назад +1

    How about a 4D plot with matplotlib?

  • @devbhatia7107
    @devbhatia7107 4 года назад

    If there is any Indian. Better you prepare for government jobs. They give good perks and allowances as compared to FAANG!

    • @devbhatia7107
      @devbhatia7107 4 года назад

      @Rahul Ranjan then leave it! Government job is best👍

    • @suraj.panddey
      @suraj.panddey 10 месяцев назад

      @@devbhatia7107 okay go prepare for govt job while sitting idle at home for 5 years :)

  • @soumadip_banerjee
    @soumadip_banerjee 4 года назад +1

    💕💕💕💕💕

  • @david-eler
    @david-eler 11 месяцев назад

    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'"

  • @matfoss1
    @matfoss1 3 года назад

    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.'

    • @nikhiljagtap1669
      @nikhiljagtap1669 3 года назад +3

      plt.plot(gas.Year, gas[country], label=country, marker=".")
      then outside the loop: plt.legend()

    • @niveditapatil4246
      @niveditapatil4246 2 года назад

      @@nikhiljagtap1669 thank you

  • @kMuhammadRayanAli
    @kMuhammadRayanAli 3 года назад

    0:09:57 ohhhhh my goshhhh!!!!!! XD

  • @hellothere1328
    @hellothere1328 4 года назад +1

    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?

    • @ayyubayyyub9415
      @ayyubayyyub9415 3 года назад

      pip install matplotlib or download anaconda that way you don't have install matplotlib.

  • @JesusJuradoMolina
    @JesusJuradoMolina Год назад

    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

  • @haval00
    @haval00 4 года назад

    Is matplotlib an engineering programm cause am studying electrical engineering though ......?????

  • @nomannawaz6385
    @nomannawaz6385 Год назад

    please share your panadas video link also ,i am not able to find it

  • @vidishakumari9320
    @vidishakumari9320 Год назад

    Can anyone share the official documentation link here

  • @shreyasnair7949
    @shreyasnair7949 3 года назад +1

    "aaaahhh"

  • @ahmedsobhygharib5978
    @ahmedsobhygharib5978 4 месяца назад

    can someone recommend to me a good video for 3D and higher dimensional graphs

  • @Lolwutdesu9000
    @Lolwutdesu9000 11 дней назад

    For anyone watching this in 2024, careful, as MatPlotLib has changed a few things and deprecated some of the functions/methods in this video.

  • @andikachsyfurdjasimilyaspa5066
    @andikachsyfurdjasimilyaspa5066 4 года назад

    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.

  • @anshrohilla53
    @anshrohilla53 9 месяцев назад

    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

  • @martinr3167
    @martinr3167 4 года назад

    Please do one numpy tutorial too 👍👍👍

    • @freecodecamp
      @freecodecamp  4 года назад

      Numpy course: ruclips.net/video/QUT1VHiLmmI/видео.html

    • @martinr3167
      @martinr3167 4 года назад

      @@freecodecamp omg you are the best guys

  • @Aisaneslamchalandar
    @Aisaneslamchalandar 11 месяцев назад

    33:05 more more

  • @KokousergeoATSU
    @KokousergeoATSU 8 месяцев назад

    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?

    • @KokousergeoATSU
      @KokousergeoATSU 8 месяцев назад

      I've found a tutorial on RUclips for the problem.

  • @bryandwayne3200
    @bryandwayne3200 4 года назад

    I have a question please ... Do I need to learn numpy or pandas before I can start freelancing with matplotlib ?

    • @antikad3701
      @antikad3701 4 года назад +2

      Yes, They are inter-related

  • @aman_0077
    @aman_0077 2 года назад

    40:29 matplotlib showed no handles with labels found to put in legend? can anyone tell me why it is not working

    • @devchaudhari1341
      @devchaudhari1341 Год назад

      just put label='country_name' argument in every plot function then use legend function