Seaborn scatter plot | How to make and style a scatterplot in Python seaborn

แชร์
ฝัง

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

  • @vinayaksharma9098
    @vinayaksharma9098 6 ชั่วโมงที่ผ่านมา

    Was looking for a Seaborn tutorial which could really help me understand everything concisely and it's the best one I found. Thank you so much, please keep it up and introduce us to some more data visualization tools and techniques :)

  • @AmanSingh-vo1fh
    @AmanSingh-vo1fh 2 ปีที่แล้ว +3

    Thanks a lot mam
    I have recently begun my DS journey and have referred to many amazing tutorials for numpy, pandas , matplotlib etc. But yours was the best one I have seen so far.
    Thanks again

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

    Thanks youu!!! I spent my time watching many tutorials that helped me very little until I found your TH-cam channel. Your videos are definitely the best.

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

      Wow -- thanks so much! Glad you are enjoying my videos and happy to hear they are helping!

    • @BrunoAraujo-po2lm
      @BrunoAraujo-po2lm 3 ปีที่แล้ว

      Totally agree!

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

    Thank you so much for sharing these content. I have watched several of your videos and they have made my life at lab way better.

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

    Thank you, that was very helpful!

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

      Super -- very glad to hear that!

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

    This video is very helpful. Tank you

    • @KimberlyFessel
      @KimberlyFessel  10 หลายเดือนก่อน

      Most welcome! Glad it helped!

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

    Excellent tutorial. Learned a lot. :)
    In minute: 1:32, what does the argument random_state means? And why did you choose = 22?

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

      Hi there -- random_state just allows for reproducibility. Since I'm selecting a random subset of the data, using random_state sets the seed of my random number generator. That means if you run this code, you will get the same random rows as me.
      And the number 22 is completely arbitrary! I often choose 42 in honor of "The Hitchhiker's Guide to the Galaxy." :) But you can pick any number you'd like.

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

      @@KimberlyFessel Thank you😃

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

    great set of videos,could you also do one to explain which plots to use when , i know it comes with practice

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

      Thanks -- I love this idea! I have been thinking about doing a few videos showing my thought process when selecting which figure to use and how I select my styling. It definitely comes with practice and depends on the data story, but maybe it would be helpful to show the thought process for a few examples. 👍

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

      @@KimberlyFessel Yes please! As a beginner, I mostly end up using bar plot, histograms and scatter plots. I would really appreciate if you could make a video on this.

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

    on setting hue, cuts with value zero like 'fair', 'ideal' are also getting plotted, how to get rid of them

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

    hey nice video!

  • @Himanshu-ed3mf
    @Himanshu-ed3mf 3 ปีที่แล้ว +2

    Though 'cut' column contains only two categories: 'Premium' and 'Good' but in legend it is showing all the categories. How it is possible?

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

      Yes, this is a relatively recent seaborn update. The data that come with seaborn have "category" data types for the strings. This means they have a property called .cat.categories. This gives all the categories (even the ones that aren't present), and this is what seaborn builds the legend from. You can override this either by not having the category data types (converting to strings, say) or by setting hue_order like I did in my recent countplot video here: th-cam.com/video/8U5h3EJuu8M/w-d-xo.html

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

    i love your vedios.. you will make me data analyst soon..

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

      Yes! All the best on your data analyst journey!

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

    Thanks!

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

    Hi! Could you explain how you get the legend to show the correct 'custom' markers, if this is even possible? (Referring to 9:10)
    Thanks a lot for these videos!

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

      Hi there -- the legend in the figure you referenced was autogenerated by Seaborn, so you can match up the hue to the diamond cut and the marker shape to the diamond color. But a couple of things:
      1. With the most recent update, Seaborn treats many columns as the "category" data type rather than strings. This means that if you do the filtering like I did in this video (with the old version of Seaborn), you will see many unused categories in the legend. You can either convert these columns to strings (with pandas .astype() method) or drop these unused categories (with pandas cat.remove_unused_categories() method: pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.cat.remove_unused_categories.html#pandas.Series.cat.remove_unused_categories) to make your legend look like mine.
      2. Also -- you can create your own custom legend if you'd like to match up the color and marker and, say, use a labels like "Premium, F", "Premium, D", etc. This StackOverflow post walks you through how you could do that: stackoverflow.com/questions/54682473/change-legend-location-and-labels-in-seaborn-scatter-plot

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

    Hi Kimberly, Thank you very much for the course! I especially like your clear explanations. I would like to add some information. I am using seaborn 0.11.2. In the diamond dataset cut, color and clarity are now type of category. So the filtered out values also appear on legend when hue is used. They also appear when you type diamonds['cut'].value_counts() with count 0. To avoid this I changed the these fields back to string with diamonds['cut'] = diamonds['cut'].astype('str'). Do you have a better solution for this? And please add this information to your notes or to the new version of this video. Thank you again.

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

    Thanks a lot!

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

    thank you so much maam

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

    thanks!! this helped a lot

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

    Hi, Dr. Fessel! Thank you so much for the video! How can I add a trend line on the scatter plot?

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

      Try using seaborn's lmplot()

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

    How do you make a midpoint for the colors?

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

    How to write text i want to show with scatter plot

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

      Hi there - you can add text to seaborn figures by using matplotlib pyplot's text function. And here is my past video on that: th-cam.com/video/NBYzSaTbodM/w-d-xo.html You can even automatically update the text positions so they don't overlap on the scatterplot using a library called AdjustText (Video here: th-cam.com/video/xSS59Ga64rQ/w-d-xo.html)

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

    hi, may I know how to change hue that shows the legend into the colorbar?

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

      Hi there - once you create your color bar you can just add it to the figure and remove the current legend. This reference should be able to help you out: stackoverflow.com/questions/62884183/trying-to-add-a-colorbar-to-a-seaborn-scatterplot

  • @kannan.s566
    @kannan.s566 3 ปีที่แล้ว

    Also explain remaining parameters

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

    Tried to annotate the figure:
    #plt.text(x_pos, y_pos, f"y = {m:.2f}x {b:.1f}", bbox=dict(facecolor='white', alpha=0.5))
    #plt.text(5, 5, f'R$^2$ = {R_value:.4f}', bbox=dict(facecolor='red', alpha=0.5))
    plt.annotate(
    # Label and coordinate
    'R$^2$ = {R_value:.4f}', xy=(5, 50), xytext=(0, 80),
    # Custom arrow
    bbox=dict(facecolor='red', alpha=0.5))
    but my y values no matter what way I try isn't going up or down.

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

    I love you Kimberly🤩🤩🤩🤩