Python Plotting Tutorial w/ Matplotlib & Pandas (Line Graph, Histogram, Pie Chart, Box & Whiskers)

///Python Plotting Tutorial w/ Matplotlib & Pandas (Line Graph, Histogram, Pie Chart, Box & Whiskers)

Python Plotting Tutorial w/ Matplotlib & Pandas (Line Graph, Histogram, Pie Chart, Box & Whiskers)

FavoriteLoadingAdd to favorites

In this video, we go through several real-world examples of using the Matplotlib & Pandas libraries to visualize data from CSV files. This is a follow-up to my introductory matplotlib video ( Timeline for what we cover can be found in the comments.

We start by creating line graphs of global gas price data over time. We review how to add a title, x & y axis labels, and scale our graph. We review how to customize the style and size of our charts. Next, we look at the FIFA 19 player data to create a histogram, a couple pie charts, and a box and whisker plot.

If you enjoy this video, make sure to LIKE and SUBSCRIBE 🙂 🙂

If you have any questions or feedback, please let me know in the comments!

———————————————

Follow me on social media!
Instagram |
Twitter |

———————————————

Link to Source Code & Datasets!

Matplotlib Documentation:

Matplotlib Fonts:

Matplotlib Style Options:

Kaggle Data Link:

———————————————

Video timeline!
0:00 – Intro & Video Overview
2:22 – Load Necessary Libraries & Download Data
3:48 – Line Graph Example (Plotting Data from CSV file)
21:52 – Histogram Example (FIFA Overall Skill Distribution)
29:25 – Pie Chart #1 (Counting data in CSV) – Visualizing Soccer Foot Preferences
36:41 – Pie Chart #2 (More advance Pandas Example) – Weight Distribution of FIFA Players
47:49 – Box & Whisker Plot (Comparing FIFA teams to one another)
1:00:37 – Final Comments

———————
Equipment I use to film my videos (I get a small commission on purchases made through these links😊)
– Sony a6500 Camera:
– Rokinon 12mm Lens:
– Rode Videomicro Microphone:
– Blue Snowball Microphone (alternate mic):
– Andycine Camera Monitor:
– Snagit for screen recording
– Adobe Premiere Pro for video editing
– Adobe Photoshop for thumbnails

source

By |2020-08-28T09:09:03+00:00August 28th, 2020|Python Video Tutorials|40 Comments

40 Comments

  1. m d August 28, 2020 at 9:09 am - Reply

    Without labels legend didn't worked. min: At 9:22 . But I appreciate your work

  2. Salil Bhatnagar August 28, 2020 at 9:09 am - Reply

    Does anyone have any idea why the imported modules (pandas, numpy, etc) work fine on Jupyter Notebook but when the same code is run in an IDE like Atom, it gives Module Not Found Error. The directories are the same.

  3. Deepak Kumar August 28, 2020 at 9:09 am - Reply

    9:07 One of the biggest problem of programmers……
    How the code worked??

  4. negar Mokhtari August 28, 2020 at 9:09 am - Reply

    really great!

  5. Priyanshu Sinha August 28, 2020 at 9:09 am - Reply

    Can you elaborate Bins in simple term, what is the use of it and why the graph changes by changing it

  6. Subhajit Adhikary August 28, 2020 at 9:09 am - Reply

    on 16:45 , to make the legend outside the graph you can use the command:-
    plt.legend(bbox_to_anchor=(1.05, 1))

  7. Sudeshna Roy August 28, 2020 at 9:09 am - Reply

    Thank you so much. Learning so much from your videos.

  8. Wild Rain August 28, 2020 at 9:09 am - Reply

    Thanks sir, is there any guidance from you on how to plot trajectories using lat and long coordinates using matlplotlib?

  9. Yuni Glücklich August 28, 2020 at 9:09 am - Reply

    this channel provides the best resource for data science in my perspective. subscribe guys, it's worth it

  10. pinak pani nath August 28, 2020 at 9:09 am - Reply

    File "<ipython-input-46-335ef5ed3a74>", line 1

    plt.plot(df.Site, df.Orders dropped Actual)

    ^

    SyntaxError: invalid syntax

  11. Lucas Phillips August 28, 2020 at 9:09 am - Reply

    26:25 I get a TypeError saying list is not callable with plt.xticks(bins)

  12. KONIKA GHOSH August 28, 2020 at 9:09 am - Reply

    Can you please provide the datasets. I cannot find the datasets

  13. Josue Ramirez August 28, 2020 at 9:09 am - Reply

    Bro your videos are the best!!!!

  14. Juan esteban Perez August 28, 2020 at 9:09 am - Reply

    thanks a lot 🙂

  15. Mahesh JS August 28, 2020 at 9:09 am - Reply

    Thank you so much for the tutorial!
    Have a small doubt, I have my data in hours of the year how do I convert it to months?
    Thank you and don't stop teaching

  16. hector motsepe August 28, 2020 at 9:09 am - Reply

    for those struggling to get labels on 17:05, use (label="%s data" % country)

  17. hector motsepe August 28, 2020 at 9:09 am - Reply

    60K SUBSCRIBERS, WOW THE COMMUNITY IS GROWING. WELL DONE KEITH

  18. Yanyo August 28, 2020 at 9:09 am - Reply

    37:23 how can I change the values to kg?

  19. anuragh ashok August 28, 2020 at 9:09 am - Reply

    Awsome…!

  20. Slappy Gustaverson August 28, 2020 at 9:09 am - Reply

    2:05 F

  21. Abhishek Tuteja August 28, 2020 at 9:09 am - Reply

    Your videos have helped me a lot to actually be interested in Data Science.
    What if in 37:40 , we have the weight column format as say 175lbs(80kg) instead of 175lbs ? How to convert that to a numerical value?

  22. Shreya Goel August 28, 2020 at 9:09 am - Reply

    Explode in not working it is showing an error

  23. Kanechul Chulikpongse August 28, 2020 at 9:09 am - Reply

    great tutorial

  24. Mücahit Uğurlu August 28, 2020 at 9:09 am - Reply

    Why do americans call football soccer? "foot – ball" it's obvious 😀 ohh.. great tutorials btw 🙂 especially Data Science Section. you're my favorite youtuber since I've found your channel

  25. digigoliath August 28, 2020 at 9:09 am - Reply

    Awesome! TQVM!!!

  26. Helio Alves August 28, 2020 at 9:09 am - Reply

    fantastic

  27. Mashfiq Rizvee August 28, 2020 at 9:09 am - Reply

    <3 <3

  28. Mateus Mattiolo August 28, 2020 at 9:09 am - Reply

    Your tutorial videos have helped me a lot to learn python. Tks

  29. muhammad bashir Muhammad August 28, 2020 at 9:09 am - Reply

    Asking questions on StackOverFlow is a service toward humanity, coz you don't know how many lives you'll save in the future. lol!

  30. Neil Virmani August 28, 2020 at 9:09 am - Reply

    Keith,
    At 38:45, to strip off 'lbs' from weights of fifa players and convert weights from string dtype to float dtype, what's your opinion on the following code:
    fifa.Weight = fifa.Weight.str[0:3].astype('float64')
    Comments from anyone are welcome.

  31. Afnan Jami August 28, 2020 at 9:09 am - Reply

    *If we make a list of the headers (ignoring the 'Year'), and then, add gas[country] instead of gas after invoking the for loop, we can avoid using the if-statement. However, your videos are amazing!! Just started learning Python and already loving it.*
    country = gas.columns[1:]
    markers = ['o', 'd', 'D', '^', '*', '>', '<', 'h', 'H', ',']
    for country in gas[country]:

    plt.plot(gas.Year, gas[country], marker = markers.pop(0), label = country)

    plt.legend(loc = 'best')

    plt.xticks(gas.Year[::3].tolist()+[2012])

  32. Mister Java August 28, 2020 at 9:09 am - Reply

    Hey, first thanks for the great Video. However, I have the following question: I dont get he syntax at 29:28
    Is this a short form? How can I calculcate or work with a specific cell within pandas DF and reset the value of the cell afterwards?
    E.g. x = x + "String"?
    More precisely, how can i loop through a column and transform the values?

  33. Hannah M August 28, 2020 at 9:09 am - Reply

    you are the single reason my grade is so good in my Data Analysis class, you are amazing and I can not thank you enough for all these videos!!!!

  34. lee hong wei August 28, 2020 at 9:09 am - Reply

    can we do a iteration on all the boxplots with the dataset?

  35. Mohale Molefe August 28, 2020 at 9:09 am - Reply

    You deserve more than a million subscribers bro! Great tutorials

  36. Rodrigo Pirôpo August 28, 2020 at 9:09 am - Reply

    One question: Matplotlib or seaborn?

  37. GermansLikeBeer August 28, 2020 at 9:09 am - Reply

    Just FYI, the pie chart section of the video no longer works. Non-1D arrays are deprecated and no longer function as of version 3.3 of MatPlotLib. So, pie charts will no longer work for the kind of data visualization described here. Bar graphs will, though. Might want to make people aware of that.

  38. Joe Moraca August 28, 2020 at 9:09 am - Reply

    I have not been able to figure out how to change the format of numbers to add commas. Say you are charting salary and you have a range from 10000 to 100000 how do I get that to show as 10,000 – 100,000 on the x or y axis?

  39. Adriana Petrova August 28, 2020 at 9:09 am - Reply

    I totally adore the way you explain. Thanks for the videos 🙂

  40. Deepa Sarojam August 28, 2020 at 9:09 am - Reply

    Great content Keith! Thanks a lot for the videos. While I was working with the Pie Chart, I couldn't make the 'label' and 'title' work, how much ever I tried! Finally, i figured out that was because I was using 'Dark Theme'. Aaah! Is there a way I can do the same with Dark Theme?

Leave A Comment

*