python:plt.pyplot.boxplot的默认设置?

时间:2014-10-08 11:31:54

标签: python matplotlib boxplot

>>>import matplotlib.pyplot as plt
>>>data = [1,2,3,4,5]                # toy data
>>>boxplot = plt.boxplot(data)

返回类型为dict的boxplot对象,其键为:

>>>boxplot.keys()
['medians', 'fliers', 'whiskers', 'boxes', 'caps']

我想知道如何查询matplotlib用来生成这些boxplot属性的默认设置。谷歌没有多大帮助。

例如,如何查询“'框”的设置。生成箱形图的属性?他们是第25和第75百分位?

1 个答案:

答案 0 :(得分:1)

您可以致电print(plt.boxplot.__doc__)

获取所需信息

以下是相关的摘录(整个事情真的很长):

whis : float, sequence (default = 1.5) or string
        As a float, determines the reach of the whiskers past the first
        and third quartiles (e.g., Q3 + whis*IQR, IQR = interquartile
        range, Q3-Q1). Beyond the whiskers, data are considered outliers
        and are plotted as individual points. Set this to an unreasonably
        high value to force the whiskers to show the min and max values.
        Alternatively, set this to an ascending sequence of percentile
        (e.g., [5, 95]) to set the whiskers at specific percentiles of
        the data. Finally, *whis* can be the string 'range' to force the
        whiskers to the min and max of the data. In the edge case that
        the 25th and 75th percentiles are equivalent, *whis* will be
        automatically set to 'range'.

所以是的,它是第25和第75百分位数,因为相对于中位数,默认值是1.5。