请找管理员授权。/funnyscript/edit_node_item.php
# -*- coding: utf-8 -*- import csv import copy import numpy as np import pandas as pd import sys import matplotlib as mpl mpl.use('Agg') import matplotlib.pyplot as plt from sklearn import svm, datasets from sklearn.metrics import roc_curve, auc ###计算roc和auc #from sklearn import cross_validation x2=[] y2=[] file='/root/happyli/Data/5716.data' title="" if len(sys.argv)>2: file=sys.argv[1] title=sys.argv[2] with open(file,'r') as csvfile: reader = csv.reader(csvfile) x2 = [row[0] for row in reader] with open(file,'r') as csvfile: reader = csv.reader(csvfile) y2 = [row[1] for row in reader] print(len(x2)) print(len(y2)) print(x2[0:100]) print(y2[0:100]) x=[] for a in x2: x.append(a) y=[] y_max=-100000; y_min=100000; for a in y2: b=float(a) if (b>y_max): y_max=b; if (b<y_min): y_min=b; y.append(b) print(len(x)) print(len(y)) print(x[0:100]) print(y[0:100]) plt.figure() #plt.rcParams['font.sans-serif']=['SimHei'] #plt.rcParams['axes.unicode_minus'] = False lw = 2 plt.figure(figsize=(10,10)) plt.legend(loc="lower right") # make a square figure plt.figure(1, figsize=(6,6)) # For China, make the piece explode a bit #expl = [0,0.1,0,0,0,0,0,0,0,0] #第二块即China离开圆心0.1 # Colors used. Recycle if not enough. colors = ["blue","red","coral","green","yellow","orange"] #设置颜色(循环显示) # Pie Plot # autopct: format of "percent" string;百分数格式 #explode=expl, plt.pie(y, colors=colors, labels= x, autopct='%1.1f%%',pctdistance=0.8, shadow=True) plt.title(title, bbox={'facecolor':'0.8', 'pad':5}) plt.savefig('/root/happyli/Data/pie.png',format='png')
ID=5842 draw_pie.py
保存
# -*- coding: utf-8 -*- import csv import copy import numpy as np import pandas as pd import sys import matplotlib as mpl mpl.use('Agg') import matplotlib.pyplot as plt from sklearn import svm, datasets from sklearn.metrics import roc_curve, auc ###计算roc和auc #from sklearn import cross_validation x2=[] y2=[] file='/root/happyli/Data/5716.data' title="" if len(sys.argv)>2: file=sys.argv[1] title=sys.argv[2] with open(file,'r') as csvfile: reader = csv.reader(csvfile) x2 = [row[0] for row in reader] with open(file,'r') as csvfile: reader = csv.reader(csvfile) y2 = [row[1] for row in reader] print(len(x2)) print(len(y2)) print(x2[0:100]) print(y2[0:100]) x=[] for a in x2: x.append(a) y=[] y_max=-100000; y_min=100000; for a in y2: b=float(a) if (b>y_max): y_max=b; if (b<y_min): y_min=b; y.append(b) print(len(x)) print(len(y)) print(x[0:100]) print(y[0:100]) plt.figure() #plt.rcParams['font.sans-serif']=['SimHei'] #plt.rcParams['axes.unicode_minus'] = False lw = 2 plt.figure(figsize=(10,10)) plt.legend(loc="lower right") # make a square figure plt.figure(1, figsize=(6,6)) # For China, make the piece explode a bit #expl = [0,0.1,0,0,0,0,0,0,0,0] #第二块即China离开圆心0.1 # Colors used. Recycle if not enough. colors = ["blue","red","coral","green","yellow","orange"] #设置颜色(循环显示) # Pie Plot # autopct: format of "percent" string;百分数格式 #explode=expl, plt.pie(y, colors=colors, labels= x, autopct='%1.1f%%',pctdistance=0.8, shadow=True) plt.title(title, bbox={'facecolor':'0.8', 'pad':5}) plt.savefig('/root/happyli/Data/pie.png',format='png')