我尝试了几个迭代版本,根据错误消息提示,使用像素或英寸方法将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错误?
谢谢。
发布于 2014-07-06 02:33:54
不支持在不指定ggsave(...)对象或事先打印它的情况下调用ggplot (但上面是一个bug,应该会打印一条用户可读消息)。
因此,要么使用gg.draw()或print(gg)打印ggplot对象,然后像上面那样调用ggsave(...),要么传入ggplot object:ggsave(gg, filename=...)。
https://stackoverflow.com/questions/24588774
复制相似问题