import matplotlib.pyplot as plt
import numpy as np
my_dpi=96
plt.figure(figsize=(480/my_dpi, 480/my_dpi), dpi=my_dpi)
x = np.random.rand(40)
y = np.random.rand(40)
z = np.random.rand(40)
plt.scatter(x, y, s=z*1000, alpha=0.5)
plt.show()
import matplotlib.pyplot as plt
import numpy as np
my_dpi=96
plt.figure(figsize=(480/my_dpi, 480/my_dpi), dpi=my_dpi)
x = np.random.rand(5)
y = np.random.rand(5)
z = np.random.rand(5)
plt.scatter(x, y, s=z*4000, c="red", alpha=0.4)
plt.show()
import matplotlib.pyplot as plt
import numpy as np
my_dpi=96
plt.figure(figsize=(480/my_dpi, 480/my_dpi), dpi=my_dpi)
x = np.random.rand(5)
y = np.random.rand(5)
z = np.random.rand(5)
plt.scatter(x, y, s=z*4000, marker="D")
plt.show()
import matplotlib.pyplot as plt
import numpy as np
my_dpi=96
plt.figure(figsize=(480/my_dpi, 480/my_dpi), dpi=my_dpi)
x = np.random.rand(5)
y = np.random.rand(5)
z = np.random.rand(5)
plt.scatter(x, y, s=z*200)
plt.show()
import matplotlib.pyplot as plt
import numpy as np
my_dpi=96
plt.figure(figsize=(480/my_dpi, 480/my_dpi), dpi=my_dpi)
x = np.random.rand(5)
y = np.random.rand(5)
z = np.random.rand(5)
plt.scatter(x, y, s=z*4000, c="green", alpha=0.4, linewidth=6)
plt.show()
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
my_dpi=96
plt.figure(figsize=(480/my_dpi, 480/my_dpi), dpi=my_dpi)
x = np.random.rand(5)
y = np.random.rand(5)
z = np.random.rand(5)
plt.scatter(x, y, s=z*4000, c="green", alpha=0.4, linewidth=6)
plt.xlabel("the X axis")
plt.ylabel("the Y axis")
plt.title("A bubble plot", loc="left")
plt.show()
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
my_dpi=96
plt.figure(figsize=(480/my_dpi, 480/my_dpi), dpi=my_dpi)
x = np.random.rand(15)
y = x+np.random.rand(15)
z = x+np.random.rand(15)
z=z*z
plt.scatter(x, y, s=z*2000, c=x, cmap="Blues", alpha=0.4, edgecolors="grey", linewidth=2)
plt.xlabel("the X axis")
plt.ylabel("the Y axis")
plt.title("A colored bubble plot")
plt.show()
import matplotlib.pyplot as plt
import numpy as np
my_dpi=96
plt.figure(figsize=(480/my_dpi, 480/my_dpi), dpi=my_dpi)
x = np.random.rand(15)
y = x+np.random.rand(15)
z = x+np.random.rand(15)
text=[chr(i) for i in range(ord('a'),ord('o')+1)]
z=z*z
plt.scatter(x, y, s=z*2000, c=x, cmap="Blues", alpha=0.4, edgecolors="grey", linewidth=2)
for i, txt in enumerate(text):
plt.text(x=x[i], y=y[i], s=txt, size=11, horizontalalignment='center', verticalalignment='center')
plt.xlabel("the X axis")
plt.ylabel("the Y axis")
plt.title("A colored bubble plot")
plt.show()
The blogger opened a new official account , I hope you can scan the code and pay attention , Thank you very much .
This article is from :https://github.com/holtzy/The-Python-Graph-Gallery/blob/master/PGG_notebook.py