程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Python drawing bubble

編輯:Python
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 


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved