如何在seaborn的小提琴情节中使用箱图的胡须参数?

时间:2017-08-10 18:55:13

标签: python matplotlib seaborn boxplot

seaborn box图有whis='range'来绘制最小/最大异常值,但小提琴图在其文档中没有这个。如何在小提琴中使用boxplot参数?

import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np

a=[195.0, 245.0, 142.0, 237.0, 153.0, 238.0, 168.0, 145.0, 229.0, 138.0, 176.0, 116.0, 252.0, 148.0, 199.0, 162.0, 134.0, 163.0, 130.0, 339.0, 152.0, 208.0, 152.0, 192.0, 163.0, 249.0, 113.0, 176.0, 123.0, 189.0, 150.0, 207.0, 184.0, 153.0, 228.0, 153.0, 170.0, 118.0, 302.0, 197.0, 211.0, 159.0, 228.0, 147.0, 166.0, 156.0, 167.0, 147.0, 126.0, 155.0, 138.0, 159.0, 139.0, 111.0, 133.0, 134.0, 131.0, 156.0, 240.0, 207.0, 150.0, 207.0, 265.0, 151.0, 173.0, 157.0, 261.0, 186.0, 195.0, 158.0, 272.0, 134.0, 221.0, 131.0, 252.0, 148.0, 178.0, 206.0, 146.0, 217.0, 159.0, 190.0, 156.0, 172.0, 159.0, 141.0, 167.0, 168.0, 218.0, 191.0, 207.0, 164.0]

fig, axes = plt.subplots()

# Seaborn violin plot
#sns.violinplot(data=a, whis='range') doesn't work
sns.violinplot(data=a)

# Normal boxplot has full range, same in Seaborn boxplot
# axes.boxplot(a, whis='range')

plt.show()

1 个答案:

答案 0 :(得分:1)

解决方案当然可以是覆盖一个正常的箱形图,它具有可用的#include <Windows.h> int main() { STARTUPINFOA startup_info = { 0 }; LPSTARTUPINFOA p_startup_info = &startup_info; PROCESS_INFORMATION proc_info = { 0 }; LPPROCESS_INFORMATION p_proc_info = &proc_info; char command_line[] = "C:\\Windows\\System32\\cmd.exe /C notepad.exe \"%USERPROFILE%\\Desktop\\test.txt\""; bool process_created = CreateProcess( NULL, command_line, NULL, NULL, FALSE, DETACHED_PROCESS, NULL, NULL, p_startup_info, p_proc_info ); if (!process_created) { return -3; } DWORD process_exit; WaitForSingleObject(proc_info.hThread, INFINITE); GetExitCodeProcess(p_proc_info->hProcess, &process_exit); return (int)process_exit; } 参数,而不是在seaborn小提琴图上。

whis='range'

enter image description here