image saving in python (matplotlib)
Question: In the code that I am working on, I have the following line:

    
    
        import pylab as pl
        pl.imsave(out_dir+'/'+fname.split('/')[-1],masked_im,vmin = 0, vmax = 1,cmap = 'gray')
    

However, I keep on getting the error that Bbox.from_bounds takes four
arguments and I have given five. I've been looking at the Python scripts for
pylab and I still can't seem to understand what may be causing this error.

Once I traced back the error, I arrived at this:

The Figure class within matplotlib has the following in the **init** function:

    
    
         self.bbox_inches = Bbox.from_bounds(0, 0, *figsize)
    

This seems to be causing the error. The image I'm trying to save is an array
in the shape of (256, 256, 3). It's figure size is 256x256. In this case
wouldn't from_bounds take four arguments ((0,0,256,256)). If not, what may be
the fifth argument and how may it be fixed?


Answer: Have you tried setting cmap to 'rgb'? I looks to me as if you have an RGB
image (256x256x3) but tell pylab to treat it as a grayscale image (256x256)

