python画盒图(csdn上最简洁的代码之一附上)

python画盒图(csdn上最简洁的代码之一附上)

画好后效果图

python画盒图(csdn上最简洁的代码之一附上)
实现代码如下

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib import pyplot
plt.style.use('seaborn-whitegrid')
palette = pyplot.get_cmap('Set1')
font1 = {'family' : 'Times New Roman',
'weight' : 'normal',
'size'   : 18,
}

fig=plt.figure(figsize=(20,10))
iters=list(range(7))
alldata1=[]#所有纵坐标数据
data=np.array([2,4,5,8,11,13,15])#单个数据
alldata1.append(data)
data=np.array([2,3,6,12,13,13,15])
alldata1.append(data)
data=np.array([2,2,7,9,13,14,16])
alldata1.append(data)
alldata1=np.array(alldata1)
allg=["alg1","alg2","alg3"]
for i in range(2):
    db=[]
    ax=fig.add_subplot(3,2,i+1)
   
    db=alldata1
    df=pd.DataFrame(db.T,columns=allg)
    df.boxplot(ax=ax,fontsize=26)
    ax.set_title("Problem is TSP",fontsize=24)
    ax.set_xlabel('Algorithms',fontsize=22)
    ax.set_ylabel('Total execution time',fontsize=22)
上一篇:在SAP CAL(Cloud Application Library)上搭建ABAP HANA系统


下一篇:计算机控制技术-2019-2020-2