matplotlib/matplotlib — pull request #1868 by pelson (2013-03-29 10:51:08+00:00)
Title: Fixed background colour of PNGs saved with a non-zero opacity.

The following code (a derivative of http://stackoverflow.com/questions/15691297/how-to-directly-set-alpha-channel-value-for-matplotlib-figure-background-colour) was producing a png with an unexpected background colour. This PR fixes the problem so that the background colour of a PNG is as expected (and consistent with SVG).

```
import matplotlib.patches as mpatches
from matplotlib.image import imread
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
from matplotlib.figure import Figure

fig = Figure()
canvas = FigureCanvas(fig)
fig.set_facecolor('black')
fig.patch.set_alpha(0.3)

fig.patches.append(mpatches.CirclePolygon([200, 200],
radius=80,
facecolor='red'))

print 'Target: ', fig.patch.get_facecolor()

fig.savefig('test_fig.png',
facecolor=fig.get_facecolor(),
edgecolor='none')
print 'Result: ', tuple(imread('test_fig.png')[0, 0])
```

Yields:

```

```

There remains a problem with PDF creation (& other backends not tested). I do not propose to fix the PDF issue in this PR.