A bubble plot is very similar to a scatterplot. Using matplotlib library, a bubble plot can be constructed using the scatter()
function. In the example, the following parameters are used:
x
: The data position on the x axisy
: The data position on the y axiss
: The marker sizealpha
: Transparancy ratio
# 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)
# show the graph
plt.show()