Here you are saving lives again. Or more specifically, hours of life with these thorough but succinct videos.. Totally in love with you and your videos 🙂
Your videos are of great value, as they are concise, practical and clear. I full-heartedly recommended them on my Twitter feed for quant investors. Keep up the good work!
Hey thank you so much for your awesome, organised and detailed didatic method! The best I've seen so far on TH-cam! I'd like to make a request. Can you please make a regular expressions series? I'd like to learn how to use them better on strings recognition and text manipulation.
Oh fun - thank you for the suggestion! I enjoy regex pattern building too - especially to help out with string cleaning for NLP or for data extraction during web scraping. I will definitely add it to the list. Glad to hear you are enjoying the content so far!
Right?! Making these recent videos about the relplot, catplot, etc, I am really amazed at all the cool things you can do with the FacetGrid and with so little code! Cheers and thanks for the support 😄
Hi Kimberly, thank you for the video :) Could you please let me know hoe exactly is the value on the y axis determined when facet grid is used? I have used it a couple of times but never figured how the y axis values are determined.
Yes! You can do this, but it's a little tricky. If you are mapping sns.scatterplot to your FacetGrid, you'll need to include both the style and markers keywords. "style" should be set to the column name of your facets (for example, if I do "col='species'" in my FacetGrid, I'll do "style='species'" in my map_dataframe method). Then "markers" should be a dictionary where the keys are the categories in your column of interest and the values are which marker you'd like to use (for example, "markers={'Adelie': 'd', 'Chinstrap': '^', 'Gentoo': 'o'}" if I'm working with the penguin species). The full code might look like this: g = sns.FacetGrid(penguins, col='species') g.map_dataframe(sns.scatterplot, x='bill_length_mm', y='bill_depth_mm', style='species', markers={'Adelie': 'd', 'Chinstrap': '^', 'Gentoo': 'o'}) Hope that helps!
Hi Kimberly! Thank you for this video. I am finding FacetGrids so useful and easy to use. The only exception is that I created 3 count plots in the FacetGrid and now I am trying to sort the bars by frequency. I created a function for this purpose to insert it in map_dataframe(), but is not working. I have tried multiple things and I cannot get my count plots to be sorted descending so they are visually easier to read. Any ideas? Thank you!
Great video! I spent so many days solving the problems and finally I am here! thank you ! I made some nice graphs but they have low resolution or low image quality when I save them as pictures, do you have any idea of that? thank you again :)
Oh wonderful! Glad to hear this video helped you. There are a few different ways to save figures. Are you using matplotlib's pyplot function? If so, you can either increase your "dots per inch" or "dpi" with plt.savefig("myfigure.png", dpi=200) - the default is 100 so increasing that will increase your resolution. Or if you are okay with switching to an svg file, that could be increased with no problem since it saves the file with vectors instead of raster dots. So that would be plt.savefig("myfigure.svg").
Hello @Kimberly ...thank for such an awesome video. I have been watching your other videos, they are very helpful. When followed your code exactly, I got an error: TypeError: add_mean_ln() missing 1 required positional argument: 'data_df' and got a plot without any horizontal mean line. My code is: def add_mean_ln( data_df, colm= None, **kws ): # if no x_var provided skip this altogether if not colm: return avg = np.mean( data_df[colm] ) # get current axis ax = plt.gca() # add v-line at the grp mean ax.axvline( avg, color= 'red', ymin=0,ymax=1, lw= 3, ls= '--' ) # annotate grp mean x_pos = 0.65 if avg > 5000: x_pos = 0.2 ax.text( x_pos,0.7, s= f'mean = {avg:.0f}', transform= ax.transAxes, # (1,1) color= 'maroon', fontweight= 'bold', fontsize= 12 ) ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ And this is how I called the facetGrid- using auto_mpg data ( my facetGrid is working well, if I don't use the custom plot function ) fctGrd1 = sns.FacetGrid( data= auto_df, col= 'cyl_class', row= 'wt_class' ) fctGrd1.map_dataframe( sns.kdeplot, x= 'mpg' ) #
Hi there - so glad you found the video useful and that you tried out the code! There's one tiny detail causing this error. The function called "add_mean_ln" needs to take in a positional argument called "data" and NOT "data_df". Strange that it has to be exactly that, but seaborn requires that any function applied via FacetGrid's map_dataframe() MUST have a position argument called exactly "data", which is how it will pass in the data from each facet. Hopefully that clears things up! Cheers!
@@KimberlyFessel Wow thanks, it works like a charm! This creating custom func for plotting will go a long way for me.... Thanks for this video and channel. Your explanation are truly cogent, concise and easy-to-understand. Wish I had a teacher like you during my undergrad. People like you makes (online) learning possible and pain-free :) Cheers!!
Spent several frustrating days looking for something like this to plug my knowledge gap. Exactly what I needed...world's greatest tutorial!
Right on! Happy you liked it!
I have never seen an explanation so beautifully put in a video. Damn! Instant subscribe
Hi! Your videos are awesome. Very clear presentation and powerful contents. Thank you!
Hi! Thanks so much! Glad you like them 😁
Thanks a lot! I now understand FacetGrid! This will be very useful.
Awesome -- glad to hear that! I agree -- the FacetGrid (along with the catplot, relplot, etc.) are super useful. So much cool functionality!
Here you are saving lives again. Or more specifically, hours of life with these thorough but succinct videos..
Totally in love with you and your videos 🙂
Why, thank you! So happy my videos have been helpful and enjoyable! 😄
You really are saving my life with your videos! Thank you
Your explanation saves me a lot of time. Thanks a lot.
Excellent - glad to hear it was helpful!
Your videos are of great value, as they are concise, practical and clear. I full-heartedly recommended them on my Twitter feed for quant investors. Keep up the good work!
So glad you are enjoying the videos and thank you very much for the recommendation on Twitter!
Thanks that is what I was looking for.
Hey thank you so much for your awesome, organised and detailed didatic method! The best I've seen so far on TH-cam!
I'd like to make a request. Can you please make a regular expressions series? I'd like to learn how to use them better on strings recognition and text manipulation.
Oh fun - thank you for the suggestion! I enjoy regex pattern building too - especially to help out with string cleaning for NLP or for data extraction during web scraping. I will definitely add it to the list. Glad to hear you are enjoying the content so far!
Seaborn FacetGrid is just awesome, and so is this tutorial video! Many thanks!
Right?! Making these recent videos about the relplot, catplot, etc, I am really amazed at all the cool things you can do with the FacetGrid and with so little code! Cheers and thanks for the support 😄
Kudos for lucid explanation!! Thank you from India.
Awesome - glad you enjoyed it! Cheers!
So nicely explained. Thanks a lot.
So glad you liked it - thanks!
Thank you! I was struggling with the hue's legend color and couldn't find the solution anywhere. Awesome tutorial btw.
So glad this video provided you with a solution - and thanks!
Okay, I love Kimberly 😭
You just saved one life today❤️.
So glad to hear it was helpful!
thank you so much for the teaching. bravo !!
Hi Kimberly, thank you for the video :)
Could you please let me know hoe exactly is the value on the y axis determined when facet grid is used? I have used it a couple of times but never figured how the y axis values are determined.
Thank you so much from France :)
De rien! Thanks for watching!
Keep it up!!! you're the best....
Thanks! 😄 Will definitely continue making more videos.
I love your videos .... thank you
Oh thank you - cheers! 😄
This is really cool
Hi Kymberly, thanks for the video
Can I change a different marker within each graph in the small multiples in Seaborn?
Yes! You can do this, but it's a little tricky. If you are mapping sns.scatterplot to your FacetGrid, you'll need to include both the style and markers keywords. "style" should be set to the column name of your facets (for example, if I do "col='species'" in my FacetGrid, I'll do "style='species'" in my map_dataframe method). Then "markers" should be a dictionary where the keys are the categories in your column of interest and the values are which marker you'd like to use (for example, "markers={'Adelie': 'd', 'Chinstrap': '^', 'Gentoo': 'o'}" if I'm working with the penguin species). The full code might look like this:
g = sns.FacetGrid(penguins, col='species')
g.map_dataframe(sns.scatterplot, x='bill_length_mm', y='bill_depth_mm', style='species', markers={'Adelie': 'd', 'Chinstrap': '^', 'Gentoo': 'o'})
Hope that helps!
@@KimberlyFessel Thanks !!
Hi Kimberly! Thank you for this video. I am finding FacetGrids so useful and easy to use. The only exception is that I created 3 count plots in the FacetGrid and now I am trying to sort the bars by frequency. I created a function for this purpose to insert it in map_dataframe(), but is not working. I have tried multiple things and I cannot get my count plots to be sorted descending so they are visually easier to read. Any ideas? Thank you!
I can’t like twice so here we go
👏👏👏
Hey you are great, keep it up!
Hey, thank you! I appreciate the kudos! 😄
Hi, I have a question, for the 'col' argument, I have nine values. How can I make it into a grid instead of nine columns in a row? (like a 4x3 grid)
Thank you so much.
Great video! I spent so many days solving the problems and finally I am here! thank you !
I made some nice graphs but they have low resolution or low image quality when I save them as pictures, do you have any idea of that?
thank you again :)
Oh wonderful! Glad to hear this video helped you. There are a few different ways to save figures. Are you using matplotlib's pyplot function? If so, you can either increase your "dots per inch" or "dpi" with plt.savefig("myfigure.png", dpi=200) - the default is 100 so increasing that will increase your resolution. Or if you are okay with switching to an svg file, that could be increased with no problem since it saves the file with vectors instead of raster dots. So that would be plt.savefig("myfigure.svg").
why did you add **kws parameter in function add_mean_ line ?
please explain...
Thanks so much
Thank you.
Most welcome!
is facetgrid same as pivot table plotting?
Yes, similar idea to the Pivot Chart in Excel. Though the facet grid can be created from the raw data instead of a pivot table.
How i can change position of titles please?
Hello @Kimberly ...thank for such an awesome video. I have been watching your other videos, they are very helpful. When followed your code exactly, I got an error:
TypeError: add_mean_ln() missing 1 required positional argument: 'data_df'
and got a plot without any horizontal mean line. My code is:
def add_mean_ln( data_df, colm= None, **kws ):
# if no x_var provided skip this altogether
if not colm: return
avg = np.mean( data_df[colm] )
# get current axis
ax = plt.gca()
# add v-line at the grp mean
ax.axvline( avg, color= 'red', ymin=0,ymax=1, lw= 3, ls= '--' )
# annotate grp mean
x_pos = 0.65
if avg > 5000: x_pos = 0.2
ax.text( x_pos,0.7, s= f'mean = {avg:.0f}',
transform= ax.transAxes, # (1,1)
color= 'maroon', fontweight= 'bold', fontsize= 12
)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
And this is how I called the facetGrid- using auto_mpg data ( my facetGrid is working well, if I don't use the custom plot function )
fctGrd1 = sns.FacetGrid( data= auto_df, col= 'cyl_class', row= 'wt_class' )
fctGrd1.map_dataframe( sns.kdeplot, x= 'mpg' ) #
Hi there - so glad you found the video useful and that you tried out the code! There's one tiny detail causing this error. The function called "add_mean_ln" needs to take in a positional argument called "data" and NOT "data_df". Strange that it has to be exactly that, but seaborn requires that any function applied via FacetGrid's map_dataframe() MUST have a position argument called exactly "data", which is how it will pass in the data from each facet. Hopefully that clears things up! Cheers!
@@KimberlyFessel Wow thanks, it works like a charm! This creating custom func for plotting will go a long way for me....
Thanks for this video and channel. Your explanation are truly cogent, concise and easy-to-understand. Wish I had a teacher like you during my undergrad.
People like you makes (online) learning possible and pain-free :) Cheers!!
I did type (g) and got “ NameError: name ‘g’ is not defined. But I can direct use g.
Oh noes! Did you execute the cell above where we assign the result of the FacetGrid to the variable g?
Thanks.
see ya
Cheers!
culmen_depth_mm, culmen_length_mm are not exist but there are bill_depth_mm, bill_length_mm
👍🏻
What is dat.query
Why you stop making videos ?
Get some sleep girl. Dark circles but great tutorial
Haha 😴😴 Appreciate the concern, but alas, my dark circles are a result of allergies and genetics. Glad you liked the tutorial nonetheless.
@@KimberlyFessel you are actually gorgeous the way you are.
please dont add adds in between the lecture as it disturbs the concentration please