I'd like to save figurecanvas as bitmap and don't need grey border around the plot in it. How can I hide this?
- @Alex, can you include some sample code that demonstrates your problem? I'm trying to code up a sample with the wxAgg backend but can not get the call to figurecanvas.tostring_rgb() to work.Mark– Mark2010-03-01 15:12:54 +00:00Commented Mar 1, 2010 at 15:12
- @Mark, if you showed me your code I could try to find the ploblem. Did you call draw() before?Alex– Alex2010-03-01 15:46:14 +00:00Commented Mar 1, 2010 at 15:46
Add a comment |
2 Answers
I believe that savefig will not include the gray border by default. However, .bmp is not support by savefig; use .png instead.
import pylab f = pylab.figure() ax = f.add_axes([0.1, 0.1, 0.8, 0.8]) ax.plot([1,2,3],[4,5,6]) f.savefig('image.png') Output:

(source: stevetjoa.com)
Comments
I found it: subplots_adjust.
1 Comment
denis
Can anyone explain how Matplotlib sizes / packs things in general ? Take for example 3 vertical subplots with titles and xlabels: how much space do title1 plot1.h xlabel1 hspace title2 ... get ?