title when using subplot

I have a plot that is divided into four subplots.

pylab.figure()
pylab.subplot(221)
pylab.plot(a,b,"k-")
pylab.subplot(222)
pylab.plot(a,b,"k-")
pylab.subplot(223)
pylab.plot(a,b,"k-")
pylab.subplot(224)
pylab.plot(a,b,"k-")

I would like to add a title to the entire plot, but pylab.title() only
applies to the most recent subplot. I have tried

pylab.figure()
pylab.subplot(111)
pylab.title("Title Here")
pylab.subplot(221)
pylab.plot(a,b,"k-")
pylab.subplot(222)
pylab.plot(a,b,"k-")
pylab.subplot(223)
pylab.plot(a,b,"k-")
pylab.subplot(224)
pylab.plot(a,b,"k-")

but this does not work as I do not create a plot for
the subplot(111) instance. Is there some way of getting
the type of title I want easily?

Cheers
   Tommy

Hi,

I was using something like this:

f = pylab.figure()
f.text(.4, .95, 'My Title') # coordinates are window coordinates from 0 to 1
pylab.subplot(421)
...

This could be made more robust by checking the extend and location of
the subplots and length of the title...

Cheers! Bernhard

···

On 1/24/08, Tommy Grav <tgrav@...935...> wrote:

I have a plot that is divided into four subplots.

pylab.figure()
pylab.subplot(221)
pylab.plot(a,b,"k-")
pylab.subplot(222)
pylab.plot(a,b,"k-")
pylab.subplot(223)
pylab.plot(a,b,"k-")
pylab.subplot(224)
pylab.plot(a,b,"k-")

I would like to add a title to the entire plot, but pylab.title() only
applies to the most recent subplot. I have tried

pylab.figure()
pylab.subplot(111)
pylab.title("Title Here")
pylab.subplot(221)
pylab.plot(a,b,"k-")
pylab.subplot(222)
pylab.plot(a,b,"k-")
pylab.subplot(223)
pylab.plot(a,b,"k-")
pylab.subplot(224)
pylab.plot(a,b,"k-")

but this does not work as I do not create a plot for
the subplot(111) instance. Is there some way of getting
the type of title I want easily?

Cheers
   Tommy

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Hi,

I was using something like this:

f = pylab.figure()
f.text(.4, .95, 'My Title') # coordinates are window coordinates from 0 to 1
pylab.subplot(421)

if you do

   >>> f.text(.5, .95, 'My Title', horizontalalignment='center')

you will get centering for free and won't have to do the .4 hack

JDH

···

On Jan 30, 2008 4:41 AM, Bernhard Voigt <Bernhard.Voigt@...1713...> wrote:

The easiest solution is the "title" keyword for subplot:

pylab.subplot(221, title='A Title for 221')

I'm using matplotlib/pylab 0.98.3

-- NTroutman

Tommy Grav wrote:

···

I have a plot that is divided into four subplots.

pylab.figure()
pylab.subplot(221)
pylab.plot(a,b,"k-")
pylab.subplot(222)
pylab.plot(a,b,"k-")
pylab.subplot(223)
pylab.plot(a,b,"k-")
pylab.subplot(224)
pylab.plot(a,b,"k-")

I would like to add a title to the entire plot, but pylab.title() only
applies to the most recent subplot. I have tried

pylab.figure()
pylab.subplot(111)
pylab.title("Title Here")
pylab.subplot(221)
pylab.plot(a,b,"k-")
pylab.subplot(222)
pylab.plot(a,b,"k-")
pylab.subplot(223)
pylab.plot(a,b,"k-")
pylab.subplot(224)
pylab.plot(a,b,"k-")

but this does not work as I do not create a plot for
the subplot(111) instance. Is there some way of getting
the type of title I want easily?

Cheers
   Tommy

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

--
View this message in context: http://www.nabble.com/title-when-using-subplot-tp15066004p22605721.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

Perhaps this is a new feature since you sent this request, but I just came
across

pylab.suptitle('my super title')

Seems to work fairly well, but the font sizes don't appear to behave as well
as I'd like.

Tommy Grav wrote:

···

I have a plot that is divided into four subplots.

pylab.figure()
pylab.subplot(221)
pylab.plot(a,b,"k-")
pylab.subplot(222)
pylab.plot(a,b,"k-")
pylab.subplot(223)
pylab.plot(a,b,"k-")
pylab.subplot(224)
pylab.plot(a,b,"k-")

I would like to add a title to the entire plot, but pylab.title() only
applies to the most recent subplot. I have tried

pylab.figure()
pylab.subplot(111)
pylab.title("Title Here")
pylab.subplot(221)
pylab.plot(a,b,"k-")
pylab.subplot(222)
pylab.plot(a,b,"k-")
pylab.subplot(223)
pylab.plot(a,b,"k-")
pylab.subplot(224)
pylab.plot(a,b,"k-")

but this does not work as I do not create a plot for
the subplot(111) instance. Is there some way of getting
the type of title I want easily?

Cheers
   Tommy

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

--
View this message in context: http://www.nabble.com/title-when-using-subplot-tp15066004p24357703.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

Just pass in the fontsize kwarg:

  pylab.suptitle('my super title', fontsize=14)

JDH

···

On Mon, Jul 6, 2009 at 10:35 AM, jcm52<joel.c.miller@...287...> wrote:

Perhaps this is a new feature since you sent this request, but I just came
across

pylab.suptitle('my super title')

Seems to work fairly well, but the font sizes don't appear to behave as well
as I'd like.