我对构建向日葵散点图很感兴趣(例如http://www.jstatsoft.org/v08/i03/paper [PDF链接]中所示)。在编写自己的实现之前,有人知道现有的实现吗?我知道Stata和R中的函数,但正在寻找matplotlib中的一个。
谢谢。
我对构建向日葵散点图很感兴趣(例如http://www.jstatsoft.org/v08/i03/paper [PDF链接]中所示)。在编写自己的实现之前,有人知道现有的实现吗?我知道Stata和R中的函数,但正在寻找matplotlib中的一个。
谢谢。
hexbin
进行计数,然后遍历每个单元格并添加相应数量的图案。:import numpy as np
import matplotlib.pyplot as plt
from matplotlib import colors
np.random.seed(0)
n = 2000
x = np.random.standard_normal(n)
y = 2.0 + 3.0 * x + 4.0 * np.random.standard_normal(n)
cmap = colors.ListedColormap(['white', 'yellow', 'orange'])
hb = plt.hexbin(x,y, bins='log', cmap=cmap, gridsize=20, edgecolor='gray')
plt.axis([-2, 2, -12, 12])
plt.title("sunflower plot")
counts = hb.get_array()
coords = hb.get_offsets()
for i, count in enumerate(counts):
x, y = coords[i,:]
count = int(10**count)
if count>3 and count<=12:
n = count // 1
if n>1:
plt.plot([x], [y], 'k.')
plt.plot([x], [y], marker=(n, 2), color='k', markersize=18)
if count>12:
n = count // 5
if n>1:
plt.plot([x], [y], 'k.')
plt.plot([x], [y], marker=(n, 2), color='k', markersize=18)
plt.show()
plt.hexbin
直方图,示例在这里:https://dev59.com/SXE95IYBdhLWcg3wSsGD#2371812。它没有顶部的标记,因此需要一些处理。 - Bonlenfum