使用pylab保存热图 [英] Saving heatmap using pylab
问题描述
我正在使用ubuntu 14.04服务器,并且从红外摄像机捕获了一些深度数据.
I am using ubuntu 14.04 server and I capturing some depth data from my infrared camera.
depth = get_depth()
print np.shape(depth)
输出为(480,640).基本上,它包含(x,y)坐标形式的深度值.
The output is (480, 640). Basically it contains depth values in the form of (x,y) coordinates.
我想将此数据另存为jpeg图片中的热图,然后从中创建MJPEG视频.但是,当我尝试做
I want to save this data as a heatmap in a jpeg picture, and then create a MJPEG video out of it. However, when I try to do
import pylab as pl
depth = get_depth()
pl.pcolor(data)
它给了我
_tkinter.TclError: no display name and no $DISPLAY environment variable
我简单地想使用savefig("filename.jpg"),并且不想使用X服务器来查看绘图.
I simple want to use savefig("filename.jpg") and dont want to use X server to see the plot.
我应该如何实现呢?还是有其他任何Python库可以生成热图并另存为JPEG文件.
How should I implement this? or is there any other python library which can generate heatmaps and save as JPEG files.
推荐答案
Matplotlib默认为使用x的后端,但是您可以通过修改rcParams来设置非交互式后端:
Matplotlib defaults to an x-using backend, but you can set a noninteractive backend by modifying rcParams:
import matplotlib
matplotlib.rcParams['backend'] = "Agg"
这篇关于使用pylab保存热图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!