AttributeError subplot2grid

Hello,
Everytime I try to run this script from the doc page of the matplotlib site :

import matplotlib.pyplot as plt
def make_ticklabels_invisible(fig):
for i, ax in enumerate(fig.axes):
ax.text(0.5, 0.5, “ax%d” % (i+1), va=“center”, ha=“center”)
for tl in ax.get_xticklabels() + ax.get_yticklabels():
tl.set_visible(False)

plt.figure(0)
ax1 = plt.subplot2grid((3,3), (0,0), colspan=3)
ax2 = plt.subplot2grid((3,3), (1,0), colspan=2)
ax3 = plt.subplot2grid((3,3), (1, 2), rowspan=2)
ax4 = plt.subplot2grid((3,3), (2, 0))
ax5 = plt.subplot2grid((3,3), (2, 1))

plt.suptitle(“subplot2grid”)
make_ticklabels_invisible(plt.gcf())
plt.show()

I get this error:
AttributeError: ‘module’ object has no attribute ‘subplot2grid’

Are some modules not installed? or is there another problem, I’m a newby in matplotlib, it might be something very obvious…

Running Matplotlib version 0.99.3 (python 2.6.6) on Ubuntu 10.10

thanks,
Hans R

I'm 90% certain that the subplot2grid feature was added in 1.0. You
could build and install from source:

https://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-1.0/

Ryan

···

On Mon, Dec 13, 2010 at 2:07 PM, vt603800 <vt603800@...3366...> wrote:

I get this error:
AttributeError: 'module' object has no attribute 'subplot2grid'

Are some modules not installed? or is there another problem, I'm a newby in
matplotlib, it might be something very obvious...

Running Matplotlib version 0.99.3 (python 2.6.6) on Ubuntu 10.10

--
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma

Yes, it is new in mpl 1.0:

http://matplotlib.sourceforge.net/users/whats_new.html

Ben Root

···

On Mon, Dec 13, 2010 at 2:13 PM, Ryan May <rmay31@…287…> wrote:

On Mon, Dec 13, 2010 at 2:07 PM, vt603800 <vt603800@…3366…> wrote:

I get this error:

AttributeError: ‘module’ object has no attribute ‘subplot2grid’

Are some modules not installed? or is there another problem, I’m a newby in

matplotlib, it might be something very obvious…

Running Matplotlib version 0.99.3 (python 2.6.6) on Ubuntu 10.10

I’m 90% certain that the subplot2grid feature was added in 1.0. You

could build and install from source:

https://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-1.0/

Ryan

I tried to upgrade to version 1.0 but without success. Could anybody tell
where it went wrong?
I downloaded the package matplotlib-1.0.0.tar.gz from
http://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-1.0/

First I tried a easy install, doing
easy_install -m matplotlib-1.0.0.tar.gz
from the command line but after this I checked the current version in Idle
and it still was 0.99

So I manually removed all the matplotlib files from /usr/lib/pymodules/
and did the easy install again from the command line
but now I can't import matplotlib anymore in Idle.

This was the installation report:

install_dir /usr/local/lib/python2.6/dist-packages/

Processing matplotlib-1.0.0.tar.gz

Running matplotlib-1.0.0/setup.py -q bdist_egg --dist-dir
/tmp/easy_install-dWh4_f/matplotlib-1.0.0/egg-dist-tmp-ohZvCJ

basedirlist is: ['/usr/local', '/usr']

···

============================================================================

BUILDING MATPLOTLIB

            matplotlib: 1.0.0

                python: 2.6.6 (r266:84292, Sep 15 2010, 16:22:56) [GCC

                        4.4.5]

              platform: linux2

REQUIRED DEPENDENCIES

                 numpy: 1.3.0

             freetype2: found, but unknown version (no pkg-config)

                        * WARNING: Could not find 'freetype2' headers in
any

                        * of '/usr/local/include', '/usr/include', '.',

                        * '/usr/local/include/freetype2',

                        * '/usr/include/freetype2', './freetype2'.

OPTIONAL BACKEND DEPENDENCIES

                libpng: found, but unknown version (no pkg-config)

                        * Could not find 'libpng' headers in any of

                        * '/usr/local/include', '/usr/include', '.'

               Tkinter: no

                        * Using default library and include directories
for

                        * Tcl and Tk because a Tk window failed to open.

                        * You may need to define DISPLAY for Tk to work so

                        * that setup can determine where your libraries
are

                        * located. Tkinter present, but header files are
not

                        * found. You may need to install development

                        * packages.

              wxPython: 2.8.11.0

                        * WxAgg extension not required for wxPython >= 2.8

            pkg-config: looking for pygtk-2.0 gtk+-2.0

                        * Package pygtk-2.0 was not found in the
pkg-config

                        * search path. Perhaps you should add the
directory

                        * containing `pygtk-2.0.pc' to the PKG_CONFIG_PATH

                        * environment variable No package 'pygtk-2.0'
found

                        * Package gtk+-2.0 was not found in the pkg-config

                        * search path. Perhaps you should add the
directory

                        * containing `gtk+-2.0.pc' to the PKG_CONFIG_PATH

                        * environment variable No package 'gtk+-2.0' found

                        * You may need to install 'dev' package(s) to

                        * provide header files.

                  Gtk+: no

                        * Could not find Gtk+ headers in any of

                        * '/usr/local/include', '/usr/include', '.'

       Mac OS X native: no

                    Qt: no

                   Qt4: no

                 Cairo: 1.8.8

OPTIONAL DATE/TIMEZONE DEPENDENCIES

              datetime: present, version unknown

              dateutil: 1.4.1

                  pytz: 2010b

OPTIONAL USETEX DEPENDENCIES

                dvipng: no

           ghostscript: 8.71

                 latex: no

               pdftops: 0.14.3

[Edit setup.cfg to suppress the above messages]

============================================================================

pymods ['pylab']

packages ['matplotlib', 'matplotlib.backends',
'matplotlib.backends.qt4_editor', 'matplotlib.projections',
'matplotlib.testing', 'matplotlib.testing.jpl_units', 'matplotlib.tests',
'mpl_toolkits', 'mpl_toolkits.mplot3d', 'mpl_toolkits.axes_grid',
'mpl_toolkits.axes_grid1', 'mpl_toolkits.axisartist',
'matplotlib.sphinxext', 'matplotlib.numerix', 'matplotlib.numerix.mlab',
'matplotlib.numerix.ma', 'matplotlib.numerix.linear_algebra',
'matplotlib.numerix.random_array', 'matplotlib.numerix.fft',
'matplotlib.tri', 'matplotlib.delaunay']

warning: no files found matching 'MANIFEST'

warning: no files found matching 'examples/data/*'

warning: no files found matching 'lib/mpl_toolkits'

gcc: error trying to exec 'cc1plus': execvp: No such file or directory

error: Setup script exited with error: command 'gcc' failed with exit
status 1

Hans R

On Mon, 13 Dec 2010 14:13:32 -0600, Ryan May <rmay31@...287...> wrote:

On Mon, Dec 13, 2010 at 2:07 PM, vt603800 <vt603800@...3366...> wrote:

I get this error:
AttributeError: 'module' object has no attribute 'subplot2grid'

Are some modules not installed? or is there another problem, I'm a

newby

in
matplotlib, it might be something very obvious...

Running Matplotlib version 0.99.3 (python 2.6.6) on Ubuntu 10.10

I'm 90% certain that the subplot2grid feature was added in 1.0. You
could build and install from source:

https://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-1.0/

Ryan

Hans,

First of all, don’t do easyinstall. Follow the instructions for building here:

http://matplotlib.sourceforge.net/users/installing.html#installing-from-source

Be sure to note the build requirements, as they need to be installed first. Also, according to your build log, you do not have gcc installed. If gcc is not installed on your linux machine, then most likely none of the needed build tools are available on your machine. This would make building numpy and other tools from source impossible. On a Fedora system, I think all you need is the ‘gcc’ package.

On a Debian-based system (like Ubuntu) you can make this whole dependency process easier with the following command:

sudo apt-get build-depends python-matplotlib

That will find (and install?) all packages that are required for building matplotlib. Be sure to first remove any previous builds of matplotlib from your system before trying this, of course.

I hope that helps!
Ben Root

···

On Tue, Dec 14, 2010 at 2:29 PM, vt603800 <vt603800@…3366…> wrote:

I tried to upgrade to version 1.0 but without success. Could anybody tell

where it went wrong?

I downloaded the package matplotlib-1.0.0.tar.gz from

http://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-1.0/

First I tried a easy install, doing

easy_install -m matplotlib-1.0.0.tar.gz

from the command line but after this I checked the current version in Idle

and it still was 0.99

So I manually removed all the matplotlib files from /usr/lib/pymodules/

and did the easy install again from the command line

but now I can’t import matplotlib anymore in Idle.

This was the installation report:

install_dir /usr/local/lib/python2.6/dist-packages/

Processing matplotlib-1.0.0.tar.gz

Running matplotlib-1.0.0/setup.py -q bdist_egg --dist-dir

/tmp/easy_install-dWh4_f/matplotlib-1.0.0/egg-dist-tmp-ohZvCJ

basedirlist is: [’/usr/local’, ‘/usr’]

============================================================================

BUILDING MATPLOTLIB

        matplotlib: 1.0.0



            python: 2.6.6 (r266:84292, Sep 15 2010, 16:22:56)  [GCC



                    4.4.5]



          platform: linux2

REQUIRED DEPENDENCIES

             numpy: 1.3.0



         freetype2: found, but unknown version (no pkg-config)



                    * WARNING: Could not find 'freetype2' headers in

any

                    * of '/usr/local/include', '/usr/include', '.',



                    * '/usr/local/include/freetype2',



                    * '/usr/include/freetype2', './freetype2'.

OPTIONAL BACKEND DEPENDENCIES

            libpng: found, but unknown version (no pkg-config)



                    * Could not find 'libpng' headers in any of



                    * '/usr/local/include', '/usr/include', '.'



           Tkinter: no



                    * Using default library and include directories

for

                    * Tcl and Tk because a Tk window failed to open.



                    * You may need to define DISPLAY for Tk to work so



                    * that setup can determine where your libraries

are

                    * located. Tkinter present, but header files are

not

                    * found. You may need to install development



                    * packages.



          wxPython: 2.8.11.0



                    * WxAgg extension not required for wxPython >= 2.8



        pkg-config: looking for pygtk-2.0 gtk+-2.0



                    * Package pygtk-2.0 was not found in the

pkg-config

                    * search path. Perhaps you should add the

directory

                    * containing `pygtk-2.0.pc' to the PKG_CONFIG_PATH



                    * environment variable No package 'pygtk-2.0'

found

                    * Package gtk+-2.0 was not found in the pkg-config



                    * search path. Perhaps you should add the

directory

                    * containing `gtk+-2.0.pc' to the PKG_CONFIG_PATH



                    * environment variable No package 'gtk+-2.0' found



                    * You may need to install 'dev' package(s) to



                    * provide header files.



              Gtk+: no



                    * Could not find Gtk+ headers in any of



                    * '/usr/local/include', '/usr/include', '.'



   Mac OS X native: no



                Qt: no



               Qt4: no



             Cairo: 1.8.8

OPTIONAL DATE/TIMEZONE DEPENDENCIES

          datetime: present, version unknown



          dateutil: 1.4.1



              pytz: 2010b

OPTIONAL USETEX DEPENDENCIES

            dvipng: no



       ghostscript: 8.71



             latex: no



           pdftops: 0.14.3

[Edit setup.cfg to suppress the above messages]

============================================================================

pymods [‘pylab’]

packages [‘matplotlib’, ‘matplotlib.backends’,

‘matplotlib.backends.qt4_editor’, ‘matplotlib.projections’,

‘matplotlib.testing’, ‘matplotlib.testing.jpl_units’, ‘matplotlib.tests’,

‘mpl_toolkits’, ‘mpl_toolkits.mplot3d’, ‘mpl_toolkits.axes_grid’,

‘mpl_toolkits.axes_grid1’, ‘mpl_toolkits.axisartist’,

‘matplotlib.sphinxext’, ‘matplotlib.numerix’, ‘matplotlib.numerix.mlab’,

matplotlib.numerix.ma’, ‘matplotlib.numerix.linear_algebra’,

‘matplotlib.numerix.random_array’, ‘matplotlib.numerix.fft’,

‘matplotlib.tri’, ‘matplotlib.delaunay’]

warning: no files found matching ‘MANIFEST’

warning: no files found matching ‘examples/data/*’

warning: no files found matching ‘lib/mpl_toolkits’

gcc: error trying to exec ‘cc1plus’: execvp: No such file or directory

error: Setup script exited with error: command ‘gcc’ failed with exit

status 1

Hans R