创建没有显示图形的png [英] create png without show figure

查看:40
本文介绍了创建没有显示图形的png的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一小段代码来绘制一些数据.

I built a small piece of code to plot some data.

我在Oracle VirtualBox上构建了它,并且可以正常工作.

I built it on my Oracle VirtualBox and it worked.

我将其移至生产环境,并让系统管理员安装代码和库等.

I moved it to production, and had the sys admin install the code and the libraries, etc.

现在 matplotlib.pyplot 部分失败了.

我尝试了一个简单的代码段

I tried a simple snippet

from matplotlib.pyplot import *
time = [0, 1, 2, 3]
position = [0, 100, 200, 300]
plt.plot(time, position)
plt.xlabel('Time (hr)')
plt.ylabel('Position (km)')

然后得到...

qt.qpa.screen:QXcbConnection:无法连接到显示器

qt.qpa.screen: QXcbConnection: Could not connect to display

我什至不想在屏幕上看到这个,我只想为网站创建一个 png.

I don't even want to see this on the screen, I just want to create a png for a web site.

你能帮我排查问题吗?

推荐答案

去掉plt."它将起作用

take off the "plt." and it will work

from matplotlib.pyplot import *
time = [0, 1, 2, 3]
position = [0, 100, 200, 300]
plot(time, position)
xlabel('Time (hr)')
ylabel('Position (km)')

这篇关于创建没有显示图形的png的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆