Open In App

Python – seaborn.pointplot() method

Seaborn is an amazing visualization library for statistical graphics plotting in Python. It provides beautiful default styles and color palettes to make statistical plots more attractive. It is built on the top of matplotlib library and also closely integrated to the data structures from pandas.

seaborn.pointplot() :

Syntax: seaborn.pointplot(x=None, y=None, hue=None, data=None, order=None,hue_order=None, estimator=<function mean at 0x00000193E305E828>, ci=95, n_boot=1000, units=None, markers=’o’, linestyles=’-‘, dodge=False, join=True, scale=1, orient=None, color=None, palette=None, errwidth=None, capsize=None, ax=None, **kwargs)



Parameters: The description of some main parameters are given below:

  • x, y: Inputs for plotting long-form data.
  • hue: (optional) column name for color encoding.
  • data: dataframe as a Dataset for plotting.
  • markers: (optional) Markers to use for each of the ‘hue’ levels.
  • linestyles: (optional) Line styles to use for each of the ‘hue’ levels.
  • dodge: (optional) Amount to separate the points for each level of the ‘hue’ variable along the categorical axis.
  • color: (optional) Color for all the elements, or seed for a gradient palette.
  • capsize: (optional) Width of the ‘caps’ on error bars.

Return: The Axes object with the plot drawn onto it.



Below is the implementation of above method:

Example 1:




# importing required packages
import seaborn as sns
import matplotlib.pyplot as plt
  
# loading dataset
data = sns.load_dataset("tips")
  
# draw pointplot
sns.pointplot(x = "sex",
              y = "total_bill",
              data = data)
# show the plot
plt.show()
# This code is contributed 
# by Deepanshu Rustagi.

Output:

Example 2:




# importing required packages
import seaborn as sns
import matplotlib.pyplot as plt
  
# loading dataset
data = sns.load_dataset("tips")
  
# draw pointplot with
# hue = smoker
sns.pointplot(x = "sex",
              y = "total_bill",
              hue = "smoker",
              data = data)
# show the plot
plt.show()
# This code is contributed 
# by Deepanshu Rustagi.

Output :

Example 3:




# importing required packages
import seaborn as sns
import matplotlib.pyplot as plt
  
# loading dataset
data = sns.load_dataset("tips")
  
# draw pointplot
sns.pointplot(x = "size",
              y = "total_bill",
              linestyles = '-.',
              markers = '^',
              hue = "sex",
              data = data)
# show the plot
plt.show()
  
# This code is contributed 
# by Deepanshu Rustagi.

Output:


Article Tags :