【问题标题】:matplotlib histtype='step' with logarithmic binning loses datamatplotlib histt​​ype='step' 与对数分箱丢失数据
【发布时间】:2016-02-23 16:49:24
【问题描述】:

我正在运行 python 版本 2.7.2(IPython,如果它有所作为) 我正在尝试使用 histt​​ype 步长和对数分箱创建一些直方图,但它似乎删除了 1 处的数据点。我正在设置 ylim(ymin=0.1) 就像其他类似问题中的海报所建议的那样,但这似乎不是来帮忙。

这是一个关于问题的最小示例:

pl.hist([1,3,3],log=True, bins=pl.logspace(0,1,10));

pl.ylim(ymin=0.1)

给出一个输出 如此处所示(按预期注意 1 和 3 处的条)

如果我现在尝试

pl.hist([1,3,3], histtype='step');

pl.ylim(ymin=0.1)

我得到如下所示的输出(再次看起来一切正常):

但是,如果我同时使用 histt​​ype='step' 和对数分箱,

pl.hist([1,3,3],log=True, bins=pl.logspace(0,1,10),histtype='step');

pl.ylim(ymin=0.1)

它变得疯狂,我得到了这个(显然缺少 1 左右的数据): .

发生了什么事?这让我疯狂!任何帮助将不胜感激。

附: - 抱歉图片链接格式错误。我没有足够的声誉来放置多个链接。有更多声誉的人可以编辑这个吗?

【问题讨论】:

  • 你的 matplotlib 版本是多少?你的最后一个例子对我来说没问题。
  • 如何查看matplotlib的版本?我只知道如何查看我的python版本
  • 执行import matplotlib,然后执行print matplotlib.__version__
  • 好的,谷歌快速搜索告诉我如何做到这一点。我在 matplotlib 版本 '1.1.0'
  • 那是一个相当旧的版本。尝试升级你的 matplotlib 版本。

标签: python matplotlib histogram


【解决方案1】:

这似乎是一个错误,因为我运行的是旧版本的 matplotlib。在 matplotlib 版本 1.5.1 中没有观察到问题

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-19
    • 1970-01-01
    • 1970-01-01
    • 2018-10-29
    • 2012-07-03
    相关资源
    最近更新 更多