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

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 (https://youtu.be/DAQNHzOcO5A). 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!

โญ Kite is a free AI-powered coding assistant that will help you code faster and smarter. The Kite plugin integrates with all the top editors and IDEs to give you smart completions and documentation while youโre typing. I’ve been using Kite for 6 months and I love it! https://www.kite.com/get-kite/?utm_medium=referral&utm_source=youtube&utm_campaign=keithgalli&utm_content=description-only

———————————————
Instagram | https://www.instagram.com/keithgalli/

———————————————
Link to Source Code & Datasets!
https://github.com/KeithGalli/matplotlib_tutorial

Matplotlib Documentation:
https://matplotlib.org/api/_as_gen/matplotlib.pyplot.html

Matplotlib Style Options:
https://matplotlib.org/3.1.0/gallery/style_sheets/style_sheets_reference.html

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

Video timeline!
0:00 – Intro & Video Overview
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)

———————
If you are curious to learn how I make my tutorials, check out this video: https://youtu.be/LEO4igyXbLs

*I use affiliate links on the products that I recommend. I may earn a purchase commission or a referral bonus from the usage of these links.

Source

### Comment List

• Keith Galli
November 11, 2020

I needed this man, thank you so much.

• Keith Galli
November 11, 2020

oh, hahah you have one about graphs as well! thanks!!!

• Keith Galli
November 11, 2020

Idk if its a new feature, but you can plot an entire dataframe using gas.plt(x = 'Year')

• Keith Galli
November 11, 2020

Nice work buddy. You made each concept so simple to understand. Love form India ๐

• Keith Galli
November 11, 2020

What shortcut do you use to uncomment and comment things?

• Keith Galli
November 11, 2020

Siempre sere del Real Madrid; este video demuestra la pura verdad y me haze triste ๐

• Keith Galli
November 11, 2020

Another great video! You're a king among men

• Keith Galli
November 11, 2020

Worth watching you, Subscribing now !

• Keith Galli
November 11, 2020

Thanks a lot Keith, you surely explain things a lot easier!
Great work man. And thanks again.

• Keith Galli
November 11, 2020

To everyone out there that wants to become a better data scientist: learn from Keith and then apply the skills on other datasets that you enjoy. That way, you can practice these skills and build your own portfolio on github at the same time. I will certainly do similar analysis on subjects of my specific interest!

• Keith Galli
November 11, 2020

awesome video!

• Keith Galli
November 11, 2020

Keith great videoโs man – clearly explained – really improving my coding skills 100% – any change you could do a matplotlib 3D wireframe contour surface heat map plots tutorial? Cheers ๐ป buddy

• Keith Galli
November 11, 2020

Thanks a lot, bro. You did well, but I think the boxplot result was needed some more explanation.

• Keith Galli
November 11, 2020

'Im going to be a little bit hackey here' Like it . Must get a T shirt printed 'A little bit Hackey'

• Keith Galli
November 11, 2020

Amazing video Keith!
I myself want to become a data analyst(because I like the business side of companies as well) and started learning python for data science/analysis over R and SAS. Really glad I found your channel ๐

• Keith Galli
November 11, 2020

You taught me more than my college teachers combined

• Keith Galli
November 11, 2020

When saving the plot as png the axes are all greyed out/transparent, i tried fiddling with transparent values in save fig but no changes. Although jpg gives a proper graph. Any solutions?

• Keith Galli
November 11, 2020

lol sometimes!

• Keith Galli
November 11, 2020

pls do tutorial on for loop and while loop

• Keith Galli
November 11, 2020

Had issues putting the x, y into the plt.plot (gas.USA, gas.whatever) Using my own CSV files. Had spaces around the headers and couldn't do the gas.whatever. Had to put them in their own variable. Y = whatever[' whatever '] and x = whatever[ 'whatever '] and worked perfect with extra white space between the quotes.

• Keith Galli
November 11, 2020

How can you save the plot to a subfolder?

• Keith Galli
November 11, 2020

Learned a lot. Thanks.

• Keith Galli
November 11, 2020

12:04 shortcut : plt.xticks(df.Year, rotation=40)

• Keith Galli
November 11, 2020

I love you keith you are really a good teacher , love from INDIA

• Keith Galli
November 11, 2020

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

• Keith Galli
November 11, 2020

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.

• Keith Galli
November 11, 2020

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

• Keith Galli
November 11, 2020

really great!

• Keith Galli
November 11, 2020

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

• Keith Galli
November 11, 2020

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

• Keith Galli
November 11, 2020

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

• Keith Galli
November 11, 2020

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

• Keith Galli
November 11, 2020

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

• Keith Galli
November 11, 2020

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

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

^

SyntaxError: invalid syntax

• Keith Galli
November 11, 2020

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