A bubble plot is very close to a scatterplot. With Matplotlib, we will construct them using the same scatter function. However, we will use the ‘s‘ argument to map a third numerical variable to the size of the marker. This will give us an additive information on the same graphic!
# libraries import matplotlib.pyplot as plt import numpy as np # create data x = np.random.rand(40) y = np.random.rand(40) z = np.random.rand(40) # use the scatter function plt.scatter(x, y, s=z*1000, alpha=0.5) plt.show()