【问题标题】:plt.errorbar issue: FutureWarning: elementwise comparison failed; returning scalar insteadplt.errorbar 问题:FutureWarning:元素比较失败;而是返回标量
【发布时间】:2016-12-06 20:44:22
【问题描述】:

当我使用 plt.errorbar 执行如下代码时,我收到以下警告消息:

FutureWarning:元素比较失败;返回标量 取而代之,但将来会执行元素比较,如果 self._edgecolors == str('face'):

import numpy as np
import matplotlib.pyplot as plt

x = np.array([1,2,3,4,5,6,7,8,9,10])
y = np.array([2,3,5,6,5,4,6,7,2,1])
yerreur = np.array([2,4,5,1,1,3,4,5,2,1])

plt.figure(1)

plt.errorbar(x,y,yerr = yerreur,fmt = 'None',ecolor = 'k')

plt.savefig('test.pdf')

plt.show()

我该如何解决这个问题?它会以任何方式影响我的图表吗?

【问题讨论】:

  • 它不会影响您的图表,只是一个警告。我在这里没有看到警告(python:3.4.3 + numpy:1.11.0 + matplotlib:1.5.1)您使用的是哪个版本?
  • 我使用的是 1.4.3 版本。
  • 我会说这是version issue。尝试更新它,我很确定会这样做;)

标签: python-3.x matplotlib graph warnings errorbar


【解决方案1】:

这个问题在 1.5.x 版本中得到了解决:

应该是 1.5 是在合并后从 master 分支出来的,它在 1.5.x 分支上

Make sure _edgecolors is a string before comparison to string

尝试将 matplotlib 更新到最新版本。

【讨论】:

    猜你喜欢
    • 2016-08-05
    • 2017-04-01
    • 2020-03-04
    • 2020-05-25
    • 2020-04-07
    • 2020-12-14
    • 2019-11-25
    • 2021-03-04
    • 2020-10-02
    相关资源
    最近更新 更多