Related Articles

Related Articles

Python Seaborn – Strip plot illustration using Catplot
  • Last Updated : 26 Nov, 2020

Seaborn is a data visualization library that is based on matplotlib. A high-level interface is provided by seaborn for drawing informative and attractive statistical graphics. Seaborn Catplot is a new addition to seaborn that makes plotting easier and involves categorical variables. It is used to show the relation between categorical variables like strip plot, box plot and so more with numerical variables.

Stripplot which is represented by strip is the default illustration in catplot().

Step-by-step Approach:

  • Import required modules.

Python3

filter_none

edit
close

play_arrow

link
brightness_4
code

# importing modules
import pandas as pnd
import matplotlib.pyplot as plt
import seaborn as sbn

chevron_right


  • Assign dataset and convert it into a data frame.

Python3



filter_none

edit
close

play_arrow

link
brightness_4
code

# fetching data from the url
  
# using pandas for reading the data file
# storing the data in input_data variable
input_data=pnd.read_csv(url_data)

chevron_right


  • Display data frame.

Python3

filter_none

edit
close

play_arrow

link
brightness_4
code

# head() function helps to see the first n rows of data
# by default n is 5 in head function
input_data.head(5)

chevron_right


Output:

  • Finally, depict the illustration.

Python3

filter_none

edit
close

play_arrow

link
brightness_4
code

# using seaborn module to show the relation betwwen 
# categorical variables and numerical variables
sbn.catplot(x='continent', y='lifeExp', data=input_data)

chevron_right


Output:

Below is the complete program based on the above approach:

Python3

filter_none

edit
close

play_arrow

link
brightness_4
code

# importing modules
import pandas as pnd
import matplotlib.pyplot as plt
import seaborn as sbn
  
  
  
# fetching data from the url
  
# using pandas for reading the data file
# storing the data in input_data variable
input_data=pnd.read_csv(url_data)
  
  
  
# using seaborn module to show the relation betwwen 
# categorical variables and numerical variables
sbn.catplot(x='continent', y='lifeExp', data=input_data)

chevron_right


Output:   


Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.




My Personal Notes arrow_drop_up
Recommended Articles
Page :