Saving heatmap using pylab

982 Views Asked by At

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

There are 1 best solutions below

0
On

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

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