Common ylabel for subplots

I don’t know how to do this in matplotlib. Can you give an example?

Chip,

I tried your method but didn’t work for me :frowning:

So
far, my best approach is use some GIMP tricks on transparent canvas.
With these improvements I am finishing my first official poster.

Thanks.
Gökhan

···

On Tue, Mar 10, 2009 at 6:01 PM, Jonathan Taylor <jonathan.taylor@…649…> wrote:

I don’t know if there is a betteer way to do it, but I think you can

just attach a text artist to the figures canvas.

Best,

J.

On Mon, Mar 9, 2009 at 12:15 PM, Gökhan SEVER <gokhansever@…287…> wrote:

Hello,

I have six subplots in my canvas, and wondering how to place a common ylabel

into the canvas in matplotlib? (Let say instead of having six same text on

the y-axes just to replace them with one bigger text encompassing all six

y-axes.)

Is this available in ml or am I too blind to see this feature?

Thanks,

Gökhan


Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA

-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise

-Strategies to boost innovation and cut costs with open source participation

-Receive a $600 discount off the registration fee with the source code: SFAD

http://p.sf.net/sfu/XcvMzF8H


Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

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

Gökhan SEVER wrote:

I don't know how to do this in matplotlib. Can you give an example?

Chip,

I tried your method but didn't work for me :frowning:

Well, I'm using matplotlib 0.98.5.2, I'm not sure if that makes a difference or not.

Here's what I'm seeing:

http://yfrog.com/090366p

It's pretty rough, but I thought it might give you an idea or two. Like I said, I've been meaning to clean up my subplots too I just haven't had time to do it. I'd be curious to see how you do it if you get it working :slight_smile:

-Chip

I'm pasting the source again in case I fumbled the last attempt:

#!/usr/bin/env python

# Make one axis that spans several subplots

from matplotlib import pyplot as plt

t = [0,1]
y = [0,1]

fig = plt.figure()

plt.axes([0.1,0.1,0.8,0.8], frameon=True, axisbg='w')
ax = fig.add_subplot(211)
plt.setp(ax.get_yticklabels(), visible=False)
plt.plot(t,y)
ax = fig.add_subplot(212)
plt.setp(ax.get_yticklabels(), visible=False)
plt.plot(t,y)
plt.show()

···

So far, my best approach is use some GIMP tricks on transparent canvas. With these improvements I am finishing my first official poster.

Thanks.
Gökhan

    On Tue, Mar 10, 2009 at 6:01 PM, Jonathan Taylor > <jonathan.taylor@…649… <mailto:jonathan.taylor@…649…>> > wrote:

        I don't know if there is a betteer way to do it, but I think you can
        just attach a text artist to the figures canvas.

        Best,
        J.

        On Mon, Mar 9, 2009 at 12:15 PM, Gökhan SEVER > <gokhansever@…287… <mailto:gokhansever@…287…>> wrote:
         > Hello,
         >
         > I have six subplots in my canvas, and wondering how to place
        a common ylabel
         > into the canvas in matplotlib? (Let say instead of having six
        same text on
         > the y-axes just to replace them with one bigger text
        encompassing all six
         > y-axes.)
         >
         > Is this available in ml or am I too blind to see this feature?
         >
         > Thanks,
         >
         > Gökhan
         >
        ------------------------------------------------------------------------------
         > Open Source Business Conference (OSBC), March 24-25, 2009,
        San Francisco, CA
         > -OSBC tackles the biggest issue in open source: Open Sourcing
        the Enterprise
         > -Strategies to boost innovation and cut costs with open
        source participation
         > -Receive a $600 discount off the registration fee with the
        source code: SFAD
         > http://p.sf.net/sfu/XcvMzF8H
         > _______________________________________________
         > Matplotlib-users mailing list
         > Matplotlib-users@lists.sourceforge.net
        <mailto:Matplotlib-users@lists.sourceforge.net>
         > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
         >

------------------------------------------------------------------------

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com

------------------------------------------------------------------------

_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Hi Gökhan et al,

I hope the following code might help you out and show you the basic
idea of sharing the same x and y axis over several subplots. I’ve made
a plot with 2 x 2 subplots sharing both x and y axis and showing only
the labels at the left and the labels at the bottom.

import pylab

figprops =
dict(figsize=(8., 8. / 1.618), dpi=128) #
Figure properties

adjustprops =
dict(left=0.1, bottom=0.1, right=0.97, top=0.93, wspace=0.08,

hspace=0.1) # Subplot
properties

fig =
pylab.figure(**figprops)

New figure

fig.subplots_adjust(**adjustprops)
# Tunes the subplot layout

ax = fig.add_subplot(2, 2, 1)

bx = fig.add_subplot(2, 2, 2, sharex=ax, sharey=ax)

cx =
fig.add_subplot(2, 2, 3, sharex=ax, sharey=ax)

dx = fig.add_subplot(2,
2, 4, sharex=ax,
sharey=ax)

ax.plot(X1, Y1, ‘k-’)

bx.plot(X2, Y2, ‘k-’)

cx.plot(X3, Y3,
‘k-’)

dx.plot(X4, Y4,
‘k-’)

pylab.setp(ax.get_xticklabels(), visible=False)

pylab.setp(bx.get_xticklabels(),
visible=False)

pylab.setp(bx.get_yticklabels(),
visible=False)

pylab.setp(dx.get_yticklabels(),
visible=False)
You can make the subplots come closer by changing the wspace
and hspace entries in the adjustprops dictionary.

Cheers,

Sebastian

Gökhan SEVER wrote:

···

I don’t know how to do this in matplotlib. Can you give an
example?

Chip,

I tried your method but didn’t work for me :frowning:

So
far, my best approach is use some GIMP tricks on transparent canvas.
With these improvements I am finishing my first official poster.

Thanks.

Gökhan

Hello Sebastian,

Not sure I could create a same-axes ylabels subplots similar to the one that is shown on the given screenshot with your code. (http://img11.imageshack.us/img11/8793/subplots.png)

Sorry haven’t managed to make LateX work on my matplotlib outputs :frowning:

Thanks for your time and consideration.

Gökhan

···

On Wed, Mar 11, 2009 at 8:49 AM, Sebastian Krieger <sebastian@…1591…> wrote:

Hi Gökhan et al,

I hope the following code might help you out and show you the basic
idea of sharing the same x and y axis over several subplots. I’ve made
a plot with 2 x 2 subplots sharing both x and y axis and showing only
the labels at the left and the labels at the bottom.

import pylab

figprops =
dict(figsize=(8., 8. / 1.618), dpi=128) #
Figure properties

adjustprops =
dict(left=0.1, bottom=0.1, right=0.97, top=0.93, wspace=0.08,

hspace=0.1) # Subplot
properties

fig =
pylab.figure(**figprops)

New figure

fig.subplots_adjust(**adjustprops)
# Tunes the subplot layout

ax = fig.add_subplot(2, 2, 1)

bx = fig.add_subplot(2, 2, 2, sharex=ax, sharey=ax)

cx =
fig.add_subplot(2, 2, 3, sharex=ax, sharey=ax)

dx = fig.add_subplot(2,
2, 4, sharex=ax,
sharey=ax)

ax.plot(X1, Y1, ‘k-’)

bx.plot(X2, Y2, ‘k-’)

cx.plot(X3, Y3,
‘k-’)

dx.plot(X4, Y4,
‘k-’)

pylab.setp(ax.get_xticklabels(), visible=False)

pylab.setp(bx.get_xticklabels(),
visible=False)

pylab.setp(bx.get_yticklabels(),
visible=False)

pylab.setp(dx.get_yticklabels(),
visible=False)
You can make the subplots come closer by changing the wspace
and hspace entries in the adjustprops dictionary.

Cheers,

Sebastian

Gökhan SEVER wrote:

I don’t know how to do this in matplotlib. Can you give an
example?

Chip,

I tried your method but didn’t work for me :frowning:

So
far, my best approach is use some GIMP tricks on transparent canvas.
With these improvements I am finishing my first official poster.

Thanks.

Gökhan

I think now I got what you want. Simply put the label on the middle
subplot. If it’s too big it will span accross the other plots.

import pylab

figprops = dict(figsize=(8., 8. / 1.618), dpi=128) # Figure properties

adjustprops = dict(left=0.1, bottom=0.1, right=0.97, top=0.93, wspace=0.2,

hspace=0.2) # Subplot properties

`fig =
pylab.figure(**figprops)

New figure`

`fig.subplots_adjust(**adjustprops)

Tunes the subplot layout`

ax = fig.add_subplot(3, 1, 1)

bx = fig.add_subplot(3, 1, 2, sharex=ax, sharey=ax)

cx = fig.add_subplot(3, 1, 3, sharex=ax, sharey=ax)

pylab.setp(ax.get_xticklabels(), visible=False)

pylab.setp(bx.get_xticklabels(), visible=False)

bx.set_ylabel('This is a long label shared among more axes', fontsize=14)

cx.set_xlabel('And a shared x label', fontsize=14)
Cheers,

Sebastian

Gökhan SEVER wrote:

···

Hello Sebastian,

Not sure I could create a same-axes ylabels subplots similar to the one
that is shown on the given screenshot with your code. (http://img11.imageshack.us/img11/8793/subplots.png)

Sorry haven’t managed to make LateX work on my matplotlib outputs :frowning:

Thanks for your time and consideration.

Gökhan

Voila,

This was what I have been looking for exactly.

Thanks for the solution.

PS: I have edited the related wiki page reflecting this method, as well:
http://www.scipy.org/Cookbook/Matplotlib/Multiple_Subplots_with_One_Axis_Label

Gökhan

···

On Thu, Mar 12, 2009 at 10:28 AM, Sebastian Krieger <sebastian@…1591…> wrote:

I think now I got what you want. Simply put the label on the middle
subplot. If it’s too big it will span accross the other plots.

import pylab

figprops = dict(figsize=(8., 8. / 1.618), dpi=128) # Figure properties

adjustprops = dict(left=0.1, bottom=0.1, right=0.97, top=0.93, wspace=0.2,

hspace=0.2) # Subplot properties

`fig =
pylab.figure(**figprops)

New figure`

`fig.subplots_adjust(**adjustprops)

Tunes the subplot layout`

ax = fig.add_subplot(3, 1, 1)

bx = fig.add_subplot(3, 1, 2, sharex=ax, sharey=ax)

cx = fig.add_subplot(3, 1, 3, sharex=ax, sharey=ax)

pylab.setp(ax.get_xticklabels(), visible=False)

pylab.setp(bx.get_xticklabels(), visible=False)

bx.set_ylabel('This is a long label shared among more axes', fontsize=14)

cx.set_xlabel('And a shared x label', fontsize=14)
Cheers,

Sebastian

Gökhan SEVER wrote:

Hello Sebastian,

Not sure I could create a same-axes ylabels subplots similar to the one
that is shown on the given screenshot with your code. (http://img11.imageshack.us/img11/8793/subplots.png)

Sorry haven’t managed to make LateX work on my matplotlib outputs :frowning:

Thanks for your time and consideration.

Gökhan