六边形分箱散点图

上一节中分箱散点图的每个分箱为矩形,本节介绍六边形分箱散点图,每个分箱是六边形的。

Document Image
\[\]

根据给定数据绘图,编写Seaborn代码如下所示:

code.python
import matplotlib.pyplot as plt    #导入Matplotlib包的pyplot子包
import pandas as pd    #导入pandas包
df=pd.read_excel('5 二元直方图.xlsx',engine=';openpyxl')    #导入数据
fig=plt.figure()    #新建绘图窗口
plt.hexbin(df.iloc[:,0],df.iloc[:,1],gridsize=20)
plt.xticks(fontsize=10)
plt.yticks(fontsize=10)
plt.show()

运行代码,生成下图。

Document Image
\[\]