Saving heatmap using pylab [duplicate]

混江龙づ霸主 提交于 2019-12-13 07:11:20

问题


I am using ubuntu 14.04 server and I capturing some depth data from my infrared camera.

depth = get_depth()
print np.shape(depth)

The output is (480, 640). Basically it contains depth values in the form of (x,y) coordinates.

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)  

It gives me

_tkinter.TclError: no display name and no $DISPLAY environment variable

I simple want to use savefig("filename.jpg") and dont want to use X server to see the plot.

How should I implement this? or is there any other python library which can generate heatmaps and save as JPEG files.


回答1:


Matplotlib defaults to an x-using backend, but you can set a noninteractive backend by modifying rcParams:

import matplotlib
matplotlib.rcParams['backend'] = "Agg"


来源:https://stackoverflow.com/questions/30961464/saving-heatmap-using-pylab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!