How do I increase the left-margin of pylab plots?

Hi,

Is there a way to increase the left-margin of pylab plots? Specifically I’m trying to make enough space so that the text labels on the left are visible. I tried decreasing the font size of the labels but it isn’t enough.

Thanks,
RHH

I figured it out.
Specifically, I need to use pylab.Axes(figure, [left, bottom, width, height]) where each value in the frame is between 0 and 1
[.2,.1,.7,.8]
means
20 percent margin on left
10 percent margin on bottom
10 percent margin on right (1 - .2 - .7)
10 percent margin on top (1 - .1 - .8)

figure = pylab.figure()
axes = pylab.Axes(figure, [.2,.1,.7,.8]) # [left, bottom, width, height] where each value is between 0 and 1
figure.add_axes(axes)

axes.barh(selectedFeatureNumbers, alphas, align='center')
axes.set_xlabel('Weights set by ViolaJones')
axes.set_title(title)
axes.set_yticks(selectedFeatureNumbers)
axes.set_yticklabels([dictionary[x][0] for x in selectedFeatureNumbers])
for tick in axes.yaxis.get_major_ticks(): tick.label1.set_fontsize(6)
pylab.savefig('%s.png' % title)
···

On Mon, Dec 8, 2008 at 12:56 AM, Roy H. Han <starsareblueandfaraway@…287…> wrote:

Hi,

Is there a way to increase the left-margin of pylab plots? Specifically I’m trying to make enough space so that the text labels on the left are visible. I tried decreasing the font size of the labels but it isn’t enough.

Thanks,
RHH

Yep, you got it.
Now, you can also use the simpler `pyplot.subplots_adjust` as a function, or as a method for your figure. That way, you're not tied to defining the positions at the creation of your subplot.

···

On Dec 8, 2008, at 1:09 AM, Roy H. Han wrote:

I figured it out.
Specifically, I need to use pylab.Axes(figure, [left, bottom, width, height]) where each value in the frame is between 0 and 1
[.2,.1,.7,.8]
means
20 percent margin on left
10 percent margin on bottom
10 percent margin on right (1 - .2 - .7)
10 percent margin on top (1 - .1 - .8)

Cool! Thanks. pyplot.subplots_adjust seems to be some kind of “super” function that controls margins for the entire figure as well as spacing between the subplots.

···

On Mon, Dec 8, 2008 at 1:32 AM, Pierre GM <pgmdevlist@…287…> wrote:

On Dec 8, 2008, at 1:09 AM, Roy H. Han wrote:

I figured it out.

Specifically, I need to use pylab.Axes(figure, [left, bottom, width,

height]) where each value in the frame is between 0 and 1

[.2,.1,.7,.8]

means

20 percent margin on left

10 percent margin on bottom

10 percent margin on right (1 - .2 - .7)

10 percent margin on top (1 - .1 - .8)

Yep, you got it.

Now, you can also use the simpler pyplot.subplots_adjust as a

function, or as a method for your figure. That way, you’re not tied to

defining the positions at the creation of your subplot.


SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.

The future of the web can’t happen without you. Join us at MIX09 to help

pave the way to the Next Web now. Learn more and register at

http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/


Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users