python:默认设置plt.pyplot.box绘图?

2024-06-28 19:34:43 发布

您现在位置:Python中文网/ 问答频道 /正文

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

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

^{pr2}$

我想知道如何查询matplotlib用来生成这些boxplot属性的默认设置。谷歌帮不了多少忙。在

例如,如何查询生成boxplots的“box”属性的设置?他们是第25百分位和第75百分位吗?在


Tags: 对象importbox类型data属性matplotlibas
1条回答
网友
1楼 · 发布于 2024-06-28 19:34:43

您只需通过调用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。在

相关问题 更多 >