📜  Python – seaborn.pointplot() 方法

📅  最后修改于: 2022-05-13 01:55:12.392000             🧑  作者: Mango

Python – seaborn.pointplot() 方法

Seaborn是一个惊人的Python统计图形绘图可视化库。它提供了漂亮的默认样式和调色板,使统计图更具吸引力。它建立在 matplotlib 库之上,并且与 pandas 的数据结构紧密集成。

seaborn.pointplot() :

  • 此方法用于使用散点图字形显示点估计值和置信区间。点图表示通过散点图点的位置对数值变量的集中趋势的估计,并使用误差条提供该估计周围的不确定性的一些指示。
  • 此函数始终将其中一个变量视为分类变量,并在相关轴上的序数位置 (0, 1, ... n) 处绘制数据,即使数据具有数字或日期类型也是如此。

下面是上述方法的实现:

示例 1:

Python3
# 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.


Python3
# 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.


Python3
# 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.


输出:

示例 2:

Python3

# 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.

输出 :

示例 3:

Python3

# 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.

输出: