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')
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With