码迷,mamicode.com
首页 > 编程语言 > 详细

python画箱线图

时间:2017-06-21 00:54:24      阅读:649      评论:0      收藏:0      [点我收藏+]

标签:normal   image   rom   marker   alpha   ipy   creat   mat   lib   

技术分享

 

# -*- coding: utf-8 -*-
"""
Created on Wed Jun 14 13:00:11 2017

@author: Miao
"""

import numpy as np 
import scipy
import matplotlib as mpl
mpl.use(‘agg‘)
import matplotlib.pyplot as plt
from matplotlib.backends.backend_pdf import PdfPages
from matplotlib import rc
font = { ‘weight‘ : ‘normal‘} 
fig = plt.figure(1, figsize=(16, 8))
pp = PdfPages(‘test_100.pdf‘)
T=[‘(a)‘,‘(b)‘,‘(c)‘,‘(d)‘,‘(e)‘,‘(f)‘];
data_name = [‘ORL‘,‘lung‘,‘JAFFE‘,‘COIL20‘,‘TOX_171‘,‘warpAR10P‘];
K = [‘5‘,‘20‘,‘100‘]
i = 1
for j in range(len(data_name)):
    data = data_name[j]
#for data in data_name:
    data1 = data+‘_100‘+‘.mat‘
    mat1 = scipy.io.loadmat(data1)
    XX = mat1[‘Acc‘]
    XX = XX*100
    ax = fig.add_subplot(2,3,i)
 
    bp = ax.boxplot(XX.T, patch_artist=True)
    if data is ‘TOX_171‘:
        data = ‘TOX\_171‘
    
    plt.title(T[j]+‘ ‘+data,fontsize=16)

    for box in bp[‘boxes‘]:
        box.set( color=‘#7570b3‘, linewidth=1)
        box.set( facecolor = ‘#1b9e77‘ )
    for whisker in bp[‘whiskers‘]:
        whisker.set(color=‘#7570b3‘, linewidth=1)
    for cap in bp[‘caps‘]:
        cap.set(color=‘#7570b3‘, linewidth=2)
    for median in bp[‘medians‘]:
        median.set(color=‘#b2df8a‘, linewidth=1)
    for flier in bp[‘fliers‘]:
        flier.set(marker=‘o‘, color=‘#e7298a‘, alpha=0.5)
#    ax.set_xticklabels([‘F\_score‘, ‘Trace\_ratio‘,‘ReliefF‘, ‘Fisher\_score‘,‘RFS‘,r‘$\ell_{2,1-2}$‘],fontdict=font)
    i=i+1
#        plt.xlabel(‘Data sets‘,fontsize=14)
    plt.ylabel(‘Accuracy (\%)‘,fontsize=16)
#    plt.ylim(ytc[j])
    plt.xticks(fontsize=16)
    plt.yticks(fontsize=16)
plt.savefig(pp,format=‘pdf‘)
pp.savefig()
pp.close()

  

python画箱线图

标签:normal   image   rom   marker   alpha   ipy   creat   mat   lib   

原文地址:http://www.cnblogs.com/huadongw/p/7057005.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!