Subplot background gradient color

colors, matplotlib, python

Solution

This doesn't use the `axisbg` parameter, but may do what you want.

There's a matplotlib example for gradients: http://matplotlib.sourceforge.net/examples/pylab_examples/gradient_bar.html. I tried it myself, this simplified version gives me a green-white gradient background (for some reason when doing this in the interactive python shell I need to call `draw()` in order for the image to show up):

import matplotlib.pyplot as mplt  
fig = mplt.figure()  
ax = fig.add_subplot(111)  
mplt.plot([1,2,3],[1,2,1])  
plotlim = mplt.xlim() + mplt.ylim()  
ax.imshow([[0,0],[1,1]], cmap=mplt.cm.Greens, interpolation='bicubic', extent=plotlim)  
mplt.draw()  

Pick another colormap for different gradients. Works without `'bicubic'` interpolation too, but it's uglier then.

Problem

How can I create some gradient color in matplotlib and then set the parameter `axisbg` of my subplot to this? ``` f = plt.figure() ax = f.add_subplot(111, axisbg='green') ```

Original source