【发布时间】:2015-04-09 19:08:42
【问题描述】:
我想知道是否有人对 Matplotlib 的箱线图传单没有显示有疑问?
我将这里的示例复制粘贴到 python 脚本中: http://blog.bharatbhole.com/creating-boxplots-with-matplotlib/
...但箱线图传单(异常值)未显示。有谁知道我为什么看不到他们?抱歉,如果这是一个愚蠢的问题,但我一生都无法弄清楚为什么它不起作用。
## Create data
np.random.seed(10)
collectn_1 = np.random.normal(100, 10, 200)
collectn_2 = np.random.normal(80, 30, 200)
collectn_3 = np.random.normal(90, 20, 200)
collectn_4 = np.random.normal(70, 25, 200)
## combine these different collections into a list
data_to_plot = [collectn_1, collectn_2, collectn_3, collectn_4]
# Create a figure instance
fig = plt.figure(1, figsize=(9, 6))
# Create an axes instance
ax = fig.add_subplot(111)
# Create the boxplot
bp = ax.boxplot(data_to_plot)
我还尝试将showfliers=True 添加到该脚本的最后一行,但它仍然无法正常工作。
这是我得到的输出:
【问题讨论】:
-
我通过复制粘贴该代码复制了原件。你还有其他加载的吗?网格/背景颜色/单位字体似乎都不标准。
-
我正在使用 iPython 笔记本......我应该提到它。这可能就是原因。你知道如何将格式设置回默认的 Matplotlib 设置吗?
标签: python matplotlib boxplot seaborn