I am starting with matplotlib and would like to generate a bubble chart. I started with the the scatter demo but I cannot understand how to prepare my data. My aim is to get this (the surfaces are in proportions 1:2:3:4)
and my code was
import matplotlib.pyplot as plt
x = [1, 2]
y = [1, 2]
x_label = ["a", "b"]
y_label = ["x", "y"]
size = [100, 200, 300, 400] # I tried wild combinations here
plt.xticks(x, x_label)
plt.yticks(y, y_label)
plt.scatter(x, y, s=size, alpha=0.5)
plt.show()
This generates the following plot (correct axis, two bubbles of relative size 1:2)
I do not know how to format the data input, size
should be made up of len(x)*len(y)
elements but how to arrange them?