不分组箱型图
import json import seaborn as sns import matplotlib.pyplot as plt fig = plt.figure(figsize=(20, 5)) sns.set(style="darkgrid") xData = [] yData = [] zData = [] with open('./files/1.txt', encoding='utf-8-sig') as f: data = json.load(f) xData = data['x']['1'] for val in data['data']['1']: yData.append(float(val)) zData.append('a') sns.boxplot(x=xData, y=yData, whis=[0, 100]) sns.stripplot(x=xData, y=yData, jitter=0.2, size=0.5) plt.savefig('./files/no-group.jpg')
分组箱型图
import json import seaborn as sns import matplotlib.pyplot as plt fig = plt.figure(figsize=(20, 5)) sns.set(style="darkgrid") # whis = [0, 100] 不显示异常点 # dodge=True 扰动点图分组 xData = [] yData = [] zData = [] with open('./files/1.txt', encoding='utf-8-sig') as f: data = json.load(f) xData = data['x']['1'] + data['x']['1'] for val in data['data']['1']: yData.append(float(val)) zData.append('a') for val in data['data']['1']: yData.append(float(val)) zData.append('b') sns.boxplot(x=xData, y=yData, hue=zData, whis=[0, 100]) sns.stripplot(x=xData, y=yData, hue=zData, dodge=True, jitter=0.2, size=0.5, legend=False) plt.savefig('./files/group.jpg')
标签:seaborn,append,yData,sns,箱型,zData,data,python3,xData From: https://www.cnblogs.com/caroline2016/p/17293057.html