2

根据错误消息提示尝试了几个迭代版本,以使用像素或英寸方法将 ggplot 保存到文件:

ggsave(filename="nlrundiff.jpg", width=4, height=4, units='in', plot=plt)

两种情况都没有成功,产生的错误信息摘录如下:

    /usr/local/lib/python2.7/dist-packages/ggplot/utils/ggutils.pyc in ggsave(filename, plot, device, format, path, scale, width, height, units, dpi, limitsize, **kwargs)
        118     from_inch = {"in":lambda x:x,"cm":lambda x: x * 2.54, "mm":lambda x: x * 2.54 * 10}
        119 
    --> 120     w, h = figure.get_size_inches()
        121     issue_size = False
        122     if width is None:

AttributeError: 'NoneType' object has no attribute 'get_size_inches'

这是我的输入语法错误还是 Python ggplot 错误?

谢谢。

4

1 回答 1

0

ggsave(...)不支持在不指定 ggplot 对象或预先打印的情况下调用(但以上是一个错误应该打印用户可读的消息)。

gg.draw()所以,要么用or打印 ggplot 对象,print(gg)然后ggsave(...)像上面那样调用,要么传入 ggplot-object: ggsave(gg, filename=...)

于 2014-07-05T18:33:54.267 回答