python - ggpy : TypeError: unorderable types: float() > NoneType()

标签 python typeerror python-ggplot

如果我写

from ggplot import *
import matplotlib.pyplot as plt
plt.figure()
ggplot(aes(x='date_hour', y='pageviews'), data=pageviews) + \
    geom_point() +\
    geom_hline(yintercept=[10000])

来自文档 http://ggplot.yhathq.com/docs/geom_hline.html我得到错误

Traceback (most recent call last):
  File "/home/user/anaconda2/envs/myenv/lib/python3.5/code.py", line 91, in runcode
    exec(code, self.locals)
  File "<input>", line 3, in <module>
  File "/home/user/anaconda2/envs/myenv/lib/python3.5/site-packages/ggplot/ggplot.py", line 116, in __repr__
    self.make()
  File "/home/user/anaconda2/envs/myenv/lib/python3.5/site-packages/ggplot/ggplot.py", line 636, in make
    layer.plot(ax, facetgroup, self._aes, **kwargs)
  File "/home/user/anaconda2/envs/myenv/lib/python3.5/site-packages/ggplot/geoms/geom_hline.py", line 36, in plot
    ax.axhline(y, **params)
  File "/home/user/anaconda2/envs/myenv/lib/python3.5/site-packages/matplotlib/axes/_axes.py", line 722, in axhline
    scaley = (yy < ymin) or (yy > ymax)
TypeError: unorderable types: float() > NoneType()

我的 ggplot 与 anaconda 一起安装在 conda-forge 的 python 3.5 上,它的版本是 0.11.5。安装 https://anaconda.org/conda-forge/ggplot

我该怎么办?

最佳答案

下面的错误说明你比较floatsNone值(value)观。

TypeError: unorderable types: float() > NoneType()

可能是你传给ggplot(...)的数据包含 None值(value)观。

  • 转储您要绘制的值。
  • 删除 None值(value)观。

理解问题:

ggplot(...)尝试将点映射到渲染区域,它进行比较 (yy < ymin) or (yy > ymax) .很可能 yy , yminymaxNone .

关于python - ggpy : TypeError: unorderable types: float() > NoneType(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42578467/

相关文章:

python - 在python ggplot中调整轴范围和刻度线

python - 导入错误 : cannot import name 'Timestamp'

python - 如何将 OrderedDict 转储为 YAML 文件?

python - Pyglet:找不到库 "GL"

python - pandas - pd.replace 和 TypeError

python - 在opencv python中进行模板匹配时出现TypeError

python - django ForeignKey 到任何类型的模型

python - 如何让用户输入列表?

Python邮件发送TypeError : Expected string or buffer

Python ggplot 旋转轴标签