Question: I have a `numpy` array **`A`**, having a shape of `(60,60,3)`, and I am using:

```
plt.imshow(  A,
             cmap          = plt.cm.gist_yarg,
             interpolation = 'nearest',
             aspect        = 'equal',
             shape         = A.shape
             )
plt.savefig( 'myfig.png' )

```

When I examine the `myfig.png` file, I see that it is 1200x800 pixels (in color).

What's going on here? I was expecting a 60x60 RGB image.

Answer: 
`matplotlib` doesn't work directly with pixels but rather a figure size (in inches) and a resolution (dots per inch, `dpi`)

So, you need to explicitly give a figure size and dpi. For example, you could set your figure size to 1x1 inches, then set the dpi to 60, to get a 60x60 pixel image.

You also have to remove the whitespace around the plot area, which you can do with `subplots_adjust`

```
import numpy as np
import matplotlib.pyplot as plt

plt.figure(figsize=(1,1))

A = np.random.rand(60,60,3)

plt.imshow(A,
           cmap=plt.cm.gist_yarg,
           interpolation='nearest',
           aspect='equal',
           shape=A.shape)

plt.subplots_adjust(left=0,right=1,bottom=0,top=1)

plt.savefig('myfig.png',dpi=60)

```

That creates this figure:

[![enter image description here](https://i.stack.imgur.com/DfygK.png)](https://i.stack.imgur.com/DfygK.png)

Which has a size of 60x60 pixels:

```
$ identify myfig.png 
myfig.png PNG 60x60 60x60+0+0 8-bit sRGB 8.51KB 0.000u 0:00.000

```

You might also refer to [this answer](https://stackoverflow.com/questions/13714454/specifying-and-saving-a-figure-with-exact-size-in-pixels), which has lots of good information about figure sizes and resolutions.
Because `plt.savefig` renders a picture from your data and has an option `dpi`, dots per inch, it is set to some default value. You can change the quality of your figure by doing `plt.savefig('myfig.png', dpi=100)`