matplotlib 提供能畫的種類
http://matplotlib.org/gallery.html
source code example included.
============================
import matplotlib.pyplot as plt
import numpy as np
#find max under list of list, sublist[x] means the target column
def max_value_lol(inputlist,target_column):
return max([sublist[target_column] for sublist in inputlist])
#畫出上下兩個圖根據不同data欄位, data is list of list , head_title is list for title
def data_Visualization(head_title,data):
#print(max_value((data)))
max_submit_times=max_value_lol(data,1)
point_scale=6
#print(len(data))
fig=plt.figure(figsize=(6,4))
ax=fig.add_subplot(211)
N = len(data)
for item in data :
x = float(item[6])
y = float(item[7])
colors = np.random.rand(N)
area = np.pi * (15 * (x+y)/2)**2
#add wording besides the points
ax.text(x, y, item[0])
#area = np.pi * (15 * (item[1]/max_submit_times)*point_scale)**2 # 0 to 15 point radiuses
plt.scatter(x, y, s=area, c=colors, alpha=0.5)
plt.xlabel(head_title[6])
plt.ylabel(head_title[7])
plt.xlim(-0.2,float (max_value_lol(data,6))+0.2)
plt.ylim(-0.2,float (max_value_lol(data,7))+0.2)
#plt.legend()
#second pic
ax=fig.add_subplot(212)
for item in data :
x = float(item[8])
y = float(item[9])
colors = np.random.rand(N)
area = np.pi * (15 * (float(item[8])+float(item[9]))/15)**2
#area = np.pi * (15 * (item[1]/max_submit_times)*point_scale)**2 # 0 to 15 point radiuses
plt.scatter(x, y, s=area, c=colors, alpha=0.5)
plt.xlabel(head_title[8])
plt.ylabel(head_title[9])
plt.xlim(-0.2,float (max_value_lol(data,8))+1)
plt.ylim(-0.2,float (max_value_lol(data,9))+5)
plt.show()
return
=====================
沒有留言:
張貼留言