这里有两个函数:hist2d_bubble和{};它们可能适合您的用途:
import numpy as np
import matplotlib.pyplot as pyplot
from mpl_toolkits.mplot3d import Axes3D
def hist2d_bubble(x_data, y_data, bins=10):
ax = np.histogram2d(x_data, y_data, bins=bins)
xs = ax[1]
ys = ax[2]
points = []
for (i, j), v in np.ndenumerate(ax[0]):
points.append((xs[i], ys[j], v))
points = np.array(points)
fig = pyplot.figure()
sub = pyplot.scatter(points[:, 0],points[:, 1],
color='black', marker='o', s=128*points[:, 2])
sub.axes.set_xticks(xs)
sub.axes.set_yticks(ys)
pyplot.ion()
pyplot.grid()
pyplot.show()
return points, sub
def hist3d_bubble(x_data, y_data, z_data, bins=10):
ax1 =