【问题标题】:ggpy: TypeError: unorderable types: float() > NoneType()ggpy:TypeError:不可排序的类型:float()> NoneType()
【发布时间】:2017-06-13 18:36:34
【问题描述】:

如果我写

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 在 conda-forge 的 python 3.5 上安装了 anaconda,它的版本是 0.11.5。用https://anaconda.org/conda-forge/ggplot安装

我该怎么办?

【问题讨论】:

    标签: python typeerror python-ggplot


    【解决方案1】:

    以下错误表示您将floatsNone 值进行比较。

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

    您传递给ggplot(...) 的数据可能包含None 值。

    • 转储您要绘制的值。
    • 删除None 值。

    理解问题:

    ggplot(...) 尝试将点映射到渲染区域时,它会比较(yy &lt; ymin) or (yy &gt; ymax)yyyminymax 很可能是 None

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-04-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-20
      • 2018-01-06
      相关资源
      最近更新 更多