Intro to Data Visualization in Python with Matplotlib! (line graph, bar chart, title, labels, size)

แชร์
ฝัง
  • เผยแพร่เมื่อ 28 ก.ค. 2024
  • Practice your Python Pandas data science skills with problems on StrataScratch! stratascratch.com/?via=keith
    Join the Python Army to get access to perks!
    TH-cam - / @keithgalli
    Patreon - / keithgalli
    Yay finally posting again. Hopefully this video will help you get comfortable working through the matplotlib library. I'm going to post a follow up video with real-world examples (combining pandas with matplotlib) and different types of plots next week. I originally was going to include that in this one, but I thought the video was getting a bit too long.
    In this video we walk through some of the basics of matplotlib. We start by making a simple line graph. We learn how to give the graph a title and label the x & y axis. We learn how to scale the graph by specifying the x & y tickmarks. After this, we restyle our line by passing in keyword arguments then do basically the same thing with a shorthand notation. We resize our graph and save it. Then we end with a simple bar chart.
    Source Code (includes code and data for next video as well):
    github.com/KeithGalli/matplot...
    Matplotlib Pyplot Documentation:
    matplotlib.org/api/_as_gen/ma...
    Font List:
    jonathansoma.com/lede/data-stu...
    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...
    Thanks for watching! Make sure to like and subscribe to not miss any future videos! Let me know if you have any questions.
    ---------------------------------------------
    Follow me on social media!
    Instagram | / keithgalli
    Twitter | / keithgalli
    --------------------------------------------
    Video Timeline:
    0:00 - Video overview (note real-world examples moved to next video)
    1:43 - Setup
    2:23 - Our first line graph!
    4:50 - Add title and labels for x & y axis
    7:13 - Change font type, size, etc.
    9:02 - Change tick marks (scale graph)
    11:20 - Add a legend
    12:25 - Restyle our line (color, line style, markers, width)
    15:53 - Shorthand notation to restyle lines
    17:27 - List of line customization options
    17:55 - Plot more complex lines
    22:20 - Resize Graph
    24:48 - Save Graph
    26:00 - Annotating/Cleaning Code
    27:00 - Bar Chart
    31:25 - Final Comments
    ---------------------
    If you are curious to learn how I make my tutorials, check out this video: • How to Make a High Qua...
    *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.

ความคิดเห็น • 182

  • @Taran72
    @Taran72 4 ปีที่แล้ว +13

    A great way to teach. I like that you show how to look for information on the referenced source. Thank you for sharing and for making these very useful online classes. :)

  • @hendrik9989
    @hendrik9989 5 ปีที่แล้ว +8

    Thank you Keith for the great video!
    This is helping my a lot for my bachelor thesis.

  • @RishikavsAnnie
    @RishikavsAnnie 3 ปีที่แล้ว +14

    I am really grateful for your tutorial videos, you cover all the must-know topics, your explanations are easy to understand and watching you make mistakes sometimes makes me comfortable as someone who's learning.
    You could totally roll out your own courses or work as a TH-camr (or become a teacher) if you want to!

  • @KeithGalli
    @KeithGalli  5 ปีที่แล้ว +56

    Happy to be back! Video Timeline:
    0:24 - Video overview (note real-world examples moved to next video)
    1:43 - Setup
    2:23 - Our first line graph!
    4:50 - Add title and labels for x & y axis
    7:13 - Change font type, size, etc.
    9:02 - Change tick marks (scale graph)
    11:20 - Add a legend
    12:25 - Restyle our line (color, line style, markers, width)
    15:53 - Shorthand notation to restyle lines
    17:27 - List of line customization options
    17:55 - Plot more complex lines
    22:20 - Resize Graph
    24:48 - Save Graph
    26:00 - Annotating/Cleaning Code
    27:00 - Bar Chart
    31:25 - Final Comments
    If you enjoyed this video, make sure to like and subscribe! :)

    • @dkd8619
      @dkd8619 5 ปีที่แล้ว

      Your videos are the best videos on python data science modules. I would like to thank you for helping people like me who wants to grow there career in python. Thanks again bro.

    • @alexyue1828
      @alexyue1828 4 ปีที่แล้ว

      Extremely beneficial for me and other, I guess. Million thanks and it will be great if you make all the tutorials series focused on different topics and provide detailed explanation of each step in the future.

    • @whmsft
      @whmsft 3 ปีที่แล้ว

      your video helped me a lot and it will also assist in my future career as a "Data Scientist" at Oracle!
      thank you!
      and what's that weird sound? here 26:43 ?

    • @robertoiglesias7910
      @robertoiglesias7910 2 ปีที่แล้ว

      25:02, almost died

  • @oliviawu1293
    @oliviawu1293 3 ปีที่แล้ว +1

    Thank you so much! I am now trying to go through every single one of your videos in data science section and have learned a lot!

  • @gintarasantis5523
    @gintarasantis5523 3 ปีที่แล้ว +2

    I like your videos, Keith! Simple, practical, to the point. Good job!

  • @jenn6997
    @jenn6997 4 ปีที่แล้ว +59

    Congrats on finishing your degree, Keith!!! :) As a student who studies Education but would like to go into data analytics, your videos are super helpful and inspiring! By any chance, you could do more videos on how to build regression models in Python? :) Again, thanks for making these amazing tutorials!! :)

  • @kristypolymath1359
    @kristypolymath1359 5 ปีที่แล้ว +2

    I watched about 2/3 of your Pandas video, it's the visual stuff that I'm after, so I'll try this one.

  • @user-yh3xt7mt4k
    @user-yh3xt7mt4k 3 ปีที่แล้ว

    You are very helpful and enjoyable. In an easy way you provide a lot of stuff to get anyone start using the libraries from scratch to a stisfying degree.

  • @harshbhatt8252
    @harshbhatt8252 4 ปีที่แล้ว +1

    thanks keith for such an amazing video on matplotlib your content is very much structured and well taught the concept in very layman terms so even a non-techie can learn concept great video keep posting more

  • @nareshreddy6484
    @nareshreddy6484 4 ปีที่แล้ว +3

    Hey Keith u are amazing at making virtual lessons with an understandable concept and ur way of teaching is quite good. Hope u will make more vedios on all the programming languages

  • @azrmuradl6420
    @azrmuradl6420 2 ปีที่แล้ว +1

    You are becoming my favorite instructor. Keep it up, man!

  • @fazlaynur4509
    @fazlaynur4509 3 ปีที่แล้ว +1

    Dude, I watch all your videos, you make videos very carefully, very instructive, thank you very much

  • @muzaianghanem5644
    @muzaianghanem5644 4 ปีที่แล้ว +2

    Thank you, I am happy I found these videos on the right time.

  • @gianluigimarudut
    @gianluigimarudut 3 ปีที่แล้ว +2

    Thank you so much for making this, Keith

  • @Pythagoras31415
    @Pythagoras31415 ปีที่แล้ว +1

    I'm finding your explanations much easier to understand than other channels.

  • @mikitakamaru
    @mikitakamaru 4 ปีที่แล้ว +1

    Thank you for this great video!! This should be helpful for all beginners of matplotlib!!

  • @alizareei4459
    @alizareei4459 4 ปีที่แล้ว +1

    it's very helpful & useful to me.
    thanks for your recording 💖

  • @TSPxEclipse
    @TSPxEclipse ปีที่แล้ว +4

    For those curious, you can use plt.annotate() to add the coordinates of markers to the graph.
    x = [your x coordinates list]
    y = [your y coordinates list]
    for i, j in zip(x, y):
    plt.annotate(f'({i}, {j})', (i, j), textcoords='offset points', xytext=(0, 5), ha='center')
    You can play around with the options, but this will add the coordinates centered slightly above the markers. If 5 seems too close, 10 is a better option.

  • @bushrag.mohammed5877
    @bushrag.mohammed5877 4 ปีที่แล้ว

    Thanks Keith, you made my day 🌟

  • @MrDaveaneo
    @MrDaveaneo 4 ปีที่แล้ว

    Knowledgeable and talented instructor.

  • @globallenz7558
    @globallenz7558 4 ปีที่แล้ว

    Thanks Keith. Keep up the great work!

  • @savinien44
    @savinien44 4 ปีที่แล้ว +1

    Thank you for the video. It's very helpful!

  • @havehalkow
    @havehalkow 4 ปีที่แล้ว +4

    An idea for a tutorial might be making a 3D plot or surface with data collected through a Tkinter application. Great video, thank you)

  • @Chitie101
    @Chitie101 4 ปีที่แล้ว

    Thank you for these, really helps!

  • @arashalizade9583
    @arashalizade9583 4 ปีที่แล้ว

    Thank you Keith this video is really awesome!

  • @harikrishna-harrypth
    @harikrishna-harrypth 3 ปีที่แล้ว

    Thanks a lot for your videos Keith, much appreciated!

  • @hiovanycubillosgomez5901
    @hiovanycubillosgomez5901 2 ปีที่แล้ว

    that's great your to took time to do these video man, thank you so much.

  • @kylieying2
    @kylieying2 5 ปีที่แล้ว +3

    Great video!!! Better than my MIT professors explain it :D

  • @robertpinochet3591
    @robertpinochet3591 23 วันที่ผ่านมา

    this video is the perfect way to understand the library

  • @raiton3778
    @raiton3778 4 ปีที่แล้ว

    Thanks dude this helped a lot! Greetings from Switzerland :))

  • @loveyoutube22
    @loveyoutube22 4 ปีที่แล้ว

    Thank you so much Keith for your videos. U make it easy to understand because u do not rush. Keep it up. U are doing a great good 🙏🙏👌👋👋

    • @finndevitt5117
      @finndevitt5117 4 ปีที่แล้ว

      sorry i have a question
      when i installing the package " plt" .
      That is displayed

      " ERROR: Could not find a version that satisfies the requirement plt (from versions: none)
      ERROR: No matching distribution found for plt
      "

      I need help :/ pls

  • @mohitjain4943
    @mohitjain4943 5 ปีที่แล้ว +20

    Finally My boy is here

    • @KeithGalli
      @KeithGalli  5 ปีที่แล้ว +2

      Sorry to be gone for so long!!!

  • @haimkichik
    @haimkichik 3 ปีที่แล้ว

    It was my fisrt vid so nice too meet you after your Academia stuff. Thanks!

  • @yusuffarah5602
    @yusuffarah5602 4 ปีที่แล้ว

    Thanks Keith. Great videos!

  • @JohnUgochukwuIsuOmo
    @JohnUgochukwuIsuOmo ปีที่แล้ว

    This video was very helpful. I had issues understanding matplotlib but I followed along and I better understood it. I also learnt how to read documentations and find what I want. Thank you.

  • @noeldoller2958
    @noeldoller2958 3 ปีที่แล้ว +1

    excellent tutorial Thumbs up to you Keith

  • @zana3d
    @zana3d 2 ปีที่แล้ว

    Thank you so much for taking the time to teach us! That exit stage left was very dramatic....

  • @piotrb5161
    @piotrb5161 5 ปีที่แล้ว +5

    Welcome back Keith👍💪

    • @KeithGalli
      @KeithGalli  5 ปีที่แล้ว

      Glad to be back! :)

  • @wheatonrecurrence9525
    @wheatonrecurrence9525 5 ปีที่แล้ว

    Thanks Keith. Do more!

  • @mahbleh404
    @mahbleh404 5 หลายเดือนก่อน

    man you are the best one so far i have seen. your tutorials are so helpful and easy to get your feet soaked into. thanks for existing

  • @phaedrus2633
    @phaedrus2633 4 ปีที่แล้ว +1

    Good videos Keith. Not draggy by any means.

  • @manishdas6525
    @manishdas6525 5 ปีที่แล้ว

    Informative & love it.

  • @itskathan7940
    @itskathan7940 3 ปีที่แล้ว

    This guy made it look so easy!

  • @harshitsharma8131
    @harshitsharma8131 2 ปีที่แล้ว

    very helpful
    thanks keith

  • @kvtr131
    @kvtr131 2 ปีที่แล้ว

    YOU ARE THE GUY ENCOURAGE AND SHARING YOUR KNOWLEDGE TO TO THE WORLD

  • @chrisintzes6239
    @chrisintzes6239 3 ปีที่แล้ว

    Nice work man!!

  • @francinagoh2541
    @francinagoh2541 4 ปีที่แล้ว

    Thanks for video to share your knowledge on python

  • @chaudiep8274
    @chaudiep8274 ปีที่แล้ว

    really like this video and your other video, thank you so much

  • @MykytaStr
    @MykytaStr 11 หลายเดือนก่อน

    Nice introduction to plotting, very useful

  • @ifiokudofe1368
    @ifiokudofe1368 ปีที่แล้ว

    thanks a lot, your videos has been very helpful

  • @Mateusz-yp3wq
    @Mateusz-yp3wq ปีที่แล้ว

    Very valuable content, thanks

  • @jorgeromero141
    @jorgeromero141 2 ปีที่แล้ว

    You are the best period.
    Hands Down

  • @tkarthikeyanai
    @tkarthikeyanai 11 หลายเดือนก่อน

    Nice brushup!

  • @nicholasnjoku4778
    @nicholasnjoku4778 ปีที่แล้ว

    Good start

  • @InteligenciadeNegocios
    @InteligenciadeNegocios 3 ปีที่แล้ว

    Thanks man, great video!

  • @vitorribeirosa
    @vitorribeirosa 3 ปีที่แล้ว

    Thanks a lot...
    Good vibes and greetings from Japan

  • @muhammadwaqar1924
    @muhammadwaqar1924 3 ปีที่แล้ว

    thank you for this video. its very very helpful.

  • @rafael040204
    @rafael040204 3 ปีที่แล้ว

    Thank you so much for this!

  • @rampedilesley9330
    @rampedilesley9330 3 ปีที่แล้ว

    Informative. Thank you so much.

  • @sunillamichhane2459
    @sunillamichhane2459 3 ปีที่แล้ว

    Greetings from Nepal ! Ur vids r superb, great help . Thank u 🙏

  • @netsurfer8923
    @netsurfer8923 3 ปีที่แล้ว

    Thank you and very helpful Video!

  • @mohammedridouane7746
    @mohammedridouane7746 3 ปีที่แล้ว +2

    "if i did 'yel' which is not a color it's gonna yell at me"
    hahhahaaha made my day
    thanks for the tutorial

  • @axeyohole4133
    @axeyohole4133 4 ปีที่แล้ว

    Hi Keith! Thanks for this video! I'm working this tutorial on my Mac and I have come across some problems executing the codes here. On the first graph you made, I had trouble showing the graph size with the plt.figure, with a dpi of 300, line because the output didn't show an enlarged version of the graph. However, when I tried to run it, it the notebook showed this result .
    Second issue is with the Bar chart's hatches. I got good results with the slash and circles on the design but on the third one with the stars, I can't get past it. It only showed the same blue bar without a single stars at all. It was worse when I tried the for loop you did because it didn't show no patterns. Weird.
    Thanks fam!

  • @maggietang1369
    @maggietang1369 4 ปีที่แล้ว

    Great job!

  • @murilosilvestre7736
    @murilosilvestre7736 2 ปีที่แล้ว

    That is supercool, thank you!

  • @harilesnar9044
    @harilesnar9044 5 ปีที่แล้ว

    Nice and simple 👌👍💥

  • @TOP--lb1rc
    @TOP--lb1rc ปีที่แล้ว

    Very Helpful

  • @Rainstorm121
    @Rainstorm121 4 ปีที่แล้ว

    Thanks Sir, any guidance on using matplotlib to plot trajectories?

  • @nasser_omar
    @nasser_omar 3 ปีที่แล้ว

    Thanks a lot, bro.
    You are amazing. Thanks for your time, but could you make a tutorial about a real project, please, so that we can use all of the libraries that you taught us?

  • @somayehseifi8269
    @somayehseifi8269 4 ปีที่แล้ว

    I like the way you teach

  • @user-ln5qj2yv7d
    @user-ln5qj2yv7d 4 ปีที่แล้ว

    hey, thank you for your videos, i'm having probloms on pycharm using the label and color via legend() and i have followed your instruction but i'm getting an attribute error: 'Line 2D' object has no property 'label' any idea why?

  • @jiangxu3895
    @jiangxu3895 4 ปีที่แล้ว +2

    Numpy-->Pandas, now I am watching Matplotlib, Thanks for you video.

    • @KeithGalli
      @KeithGalli  4 ปีที่แล้ว

      Love it!!

    • @_matis_
      @_matis_ 4 ปีที่แล้ว

      hahaha,same order here...

  • @bdharani1620
    @bdharani1620 2 ปีที่แล้ว

    Sir your explanation so clear and I understand very easily please make more videos on python for freshers but I have a doubt how we are use some string,list ,set, dictionary methods in class , please make one video with above data types mothods please sir thank you for sharing this video

  • @kasimshobak3281
    @kasimshobak3281 4 ปีที่แล้ว

    Thank you!

  • @leolee2525
    @leolee2525 4 ปีที่แล้ว +1

    Hi Keith. Thanks a lot for this video. I got " invalid character in identifier" in Jupyther on the line "plt.title('Our First Graph',fontdict = {'fontname':'Comic Sans MS'})", any idea what's the problem?

  • @jongcheulkim7284
    @jongcheulkim7284 3 ปีที่แล้ว

    Thank you so much.

  • @rverm1000
    @rverm1000 4 ปีที่แล้ว

    very helpful

  • @graceteo8296
    @graceteo8296 4 ปีที่แล้ว +1

    Hi. Can we create a project timeline using pandas? Thanks

  • @Tech-du2bg
    @Tech-du2bg 2 ปีที่แล้ว

    Very helpful video. I tried the same process on my exercise but stacked where they said x and y must have same first dimension, but have shapes (30, 30) and (1,). I checked my x and y find they have the same dimension but I am not sure about z because it has 3D data. How can I solve it?

  • @fazlullahmohammed2867
    @fazlullahmohammed2867 4 ปีที่แล้ว

    Can u make a vedio on how to implement tooltip in phython graphs..

  • @topfundus1093
    @topfundus1093 2 ปีที่แล้ว

    Sehr gut! Vielen Dank und viele Grüße aus Deutschland!

  • @pinakpaninath4321
    @pinakpaninath4321 4 ปีที่แล้ว

    Any regression model or clustering model from scratch Keith, looking forward to it

  • @dr.mohamedaitnouh4501
    @dr.mohamedaitnouh4501 ปีที่แล้ว

    Nice intro easy to follow but one must do what it says not only listen ... I learned that we must put legend() to be able to see label =('') .... thank you

  • @1UniverseGames
    @1UniverseGames 3 ปีที่แล้ว +1

    On that line graph, how can we use logo at the end of this line. Suppose if we want to use Facebook and Twitter logo, small size or even how can make a circle and write"FB" or Twitter like this at the end of each multiple line.

  • @jatinkumar4410
    @jatinkumar4410 3 ปีที่แล้ว

    Nice tutorial...

  • @tobiasksr23
    @tobiasksr23 4 ปีที่แล้ว

    Eres un grande, maestro.

    • @KeithGalli
      @KeithGalli  4 ปีที่แล้ว +1

      Muchas gracias 😄

  • @ousmanekaba8808
    @ousmanekaba8808 2 ปีที่แล้ว

    Thank you sir

  • @hectormotsepe1581
    @hectormotsepe1581 4 ปีที่แล้ว

    Thanks man.

  • @lakshyapratapsigh3518
    @lakshyapratapsigh3518 3 ปีที่แล้ว

    THANK YOU KEITH LOVE FROM INDIA

  • @solomonmuwori1954
    @solomonmuwori1954 3 ปีที่แล้ว

    Hi Keith. Thanks for your Videos - they demystify the subject matter. I Had issues registering and importing Matplotlib in Visual Studio Code (free version). Only able to plot with Matplotlib when using Jupyter Notebook. Can you assist in getting Matplotlib running in Visual Studio Code?

  • @horaciob7985
    @horaciob7985 3 ปีที่แล้ว

    nice job

  • @usmannomani2647
    @usmannomani2647 4 ปีที่แล้ว +1

    I have csv data of one city which is I have been read in python using panda library now I want to extract specific area of that city How would I do this ? Which Library would I use for this purpose ?
    Csv City data contains (Lat & Long )

  • @michaelabugri-attan5845
    @michaelabugri-attan5845 2 ปีที่แล้ว

    Thank you
    But can you plot an ogive or cumulative frequency curve using matplotlib???

  • @frankservant5754
    @frankservant5754 2 ปีที่แล้ว

    Really cool

  • @Zielu13
    @Zielu13 2 ปีที่แล้ว

    Thanks. Do you know how to change the background color in dataframe.plot graphs ( the background on which there are: labels and graph name). In subplots you can use 'facecolor' param, but it doesn't work in plots generated from multiindex dataframes.

  • @jingwu1425
    @jingwu1425 4 ปีที่แล้ว

    Thanks Keith! Can you make a video showing how to draw a box with 10 rows and 10 columns, total 100 grids, and each grid contains a value from a file. Like a storage box.

    • @lei_surevictor6252
      @lei_surevictor6252 2 ปีที่แล้ว

      你好,请问这个问题你解决了么?😃

  • @eleonoraamante4716
    @eleonoraamante4716 4 ปีที่แล้ว

    Hello Keith! I have watched few of your videos and they are very interesting and helpfull.
    Now I have a problem with the installation of matplotlib. I have tried both the "pip" and the Anaconda options. It seems to be installed, I can find the folder into the directory, but when I try to import it, I get the error "No module named 'matplotlib'".
    There is a trick that I do not know to solve the problem?
    Thank you!!

    • @TreeCube
      @TreeCube 3 ปีที่แล้ว +1

      import matplotlib.pyplot
      # it's 'matplotlib.pyplot', not 'matplotlib'

  • @bapinchakraborty5329
    @bapinchakraborty5329 4 ปีที่แล้ว +1

    You are super awesome bro love yuh 👌👌👌👍👍

  • @deepanshuverma1215
    @deepanshuverma1215 2 ปีที่แล้ว

    Sir, please make more tutorials related to Projects on Data Science