import pylab produces rounding error

Hi,

I'm quite a newbie on matplotlib.

I'm trying to get some data from a file. I've got a function that reads the data from the file and stores it in a tuple as a set of floats. When I use this without importing pylab it just go well but when I do it after importing this module there's a rounding and I don't get the proper data:

···

----------------------------
>>> import myModule as m
>>> spc = m.Collection()
>>> spc.ReadCollection('file')
>>> sp = spc.GetCSVBlock('00074')
>>> sp.GetDataRecord(0)
(0.0, 0.10000000000000001, 0.050345000000000001, 616.0, 24.818999999999999, 616.0)

---

>>> import myModule as m
>>> from pylab import *
>>> spc = m.Collection()
>>> spc.ReadCollection('file')
>>> sp = spc.GetCSVBlock('00074')
>>> sp.GetDataRecord(0)
(0.0, 0.0, 0.0, 616.0, 24.0, 616.0)
----------------------------

What's the problem here? What can I do to avoid it?

Thanks in advance,

AR

Angela Rivera Campos wrote:

Hi,

I'm quite a newbie on matplotlib.

I'm trying to get some data from a file. I've got a function that reads the data from the file and stores it in a tuple as a set of floats. When I use this without importing pylab it just go well but when I do it after importing this module there's a rounding and I don't get the proper data:

----------------------------
>>> import myModule as m
>>> spc = m.Collection()
>>> spc.ReadCollection('file')
>>> sp = spc.GetCSVBlock('00074')
>>> sp.GetDataRecord(0)
(0.0, 0.10000000000000001, 0.050345000000000001, 616.0, 24.818999999999999, 616.0)

---

>>> import myModule as m
>>> from pylab import *
>>> spc = m.Collection()
>>> spc.ReadCollection('file')
>>> sp = spc.GetCSVBlock('00074')
>>> sp.GetDataRecord(0)
(0.0, 0.0, 0.0, 616.0, 24.0, 616.0)
----------------------------

What's the problem here? What can I do to avoid it?

Try

   import pylab

instead of

   from pylab import *

Manuel

···

Thanks in advance,

AR

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Try

  import pylab

instead of

  from pylab import *

Manuel

I've already tried using
  
  import pylab

and also just importing the functions that I'm using, but the result is always the same.

AR

Hi,

I'm quite a newbie on matplotlib.

I'm trying to get some data from a file. I've got a function that reads
the data from the file and stores it in a tuple as a set of floats. When
I use this without importing pylab it just go well but when I do it
after importing this module there's a rounding and I don't get the
proper data:

My guess is there is something triggered by a pylab
numpy/numerix/Numeric import, but w/o kjnowing more about your
matplotlib and other software versions is it difficult to guess.
Could you put these lines into a test script and run them with

python myscript.py --verbose-debug

and paste the output.

Florian Koelling recently reported a problem that sounded very similar
under the heading "mad interference between matplotlib and openbabel".
Apparently some pylab import is doing something funky with some third
party libs.

Could you test just the numpy imports to see if that makes a
difference. Ie, instead of importing pylab before your module code,
do the following:

import numpy
import numpy.fft
importnumpy.random
import numpy.linalg

and let us know if you see similar problems.

JDH

JDH

···

On Thu, Jul 10, 2008 at 6:42 AM, Angela Rivera Campos <riveraca@...2087...> wrote:

First of all, thank you all for the help.

> My guess is there is something triggered by a pylab
> numpy/numerix/Numeric import, but w/o kjnowing more about your
> matplotlib and other software versions is it difficult to guess.
> Could you put these lines into a test script and run them with
>
>> python myscript.py --verbose-debug
>
> and paste the output.

Here's the output for my dummy script. I'm using pylab functions: show, figure and bar, though just importing pylab without actually using the functions produces the same problems, that's why at first I thought the problem is related with something in the import.

···

-----------
matplotlib data path usr/lib/python2.5/site-packages/matplotlib/mpl-data
$HOME=/home/myhome
CONFIGDIR=/home/myhome/.matplotlib
loaded rc file /home/myhome/.matplotlib/matplotlibrc
matplotlib version 0.90.1
verbose.level debug
interactive is False
units is True
platform is linux2
loaded modules: ['pylab', 'distutils.distutils', '_bisect', '__future__', 'copy_reg', 'sre_compile', 'distutils', 'itertools', '_hashlib', '_sre', '__main__', 'site', '__builtin__', 'datetime', 'distutils.re', 'matplotlib.re', 'matplotlib.tempfile', 'encodings', 'encodings.encodings', 'shutil', 'distutils.string', 'dateutil', 'matplotlib.datetime', 'posixpath', '_random', 'tempfile', 'errno', 'matplotlib.warnings', 'binascii', 'encodings.codecs', 'sre_constants', 're', 'matplotlib.md5', 'os.path', 'pytz.sys', '_codecs', 'distutils.sysconfig', 'pytz.sets', 'math', 'fcntl', 'stat', 'zipimport', 'string', 'warnings', 'encodings.types', 'UserDict', 'encodings.utf_8', 'matplotlib', 'distutils.os', 'sys', 'pytz.tzinfo', 'pytz', 'pytz.datetime', 'matplotlib.__future__', 'codecs', 'matplotlib.sys', 'matplotlib.pytz', 'types', 'md5', '_types', 'matplotlib.dateutil', 'hashlib', 'matplotlib.os', 'thread', 'bisect', 'matplotlib.distutils', 'signal', 'distutils.errors', 'random', 'linecache', 'matplotlib.shutil', 'posix', 'encodings.aliases', 'sets', 'exceptions', 'sre_parse', 'pytz.bisect', 'distutils.sys', 'os', 'strop']
numerix numpy 1.0.3
font search path ['/usr/lib/python2.5/site-packages/matplotlib/mpl-data/fonts/ttf', '/usr/lib/python2.5/site-packages/matplotlib/mpl-data/fonts/afm']
trying fontname /usr/lib/python2.5/site-packages/matplotlib/mpl-data/fonts/ttf/VeraMoIt.ttf
trying fontname /usr/lib/python2.5/site-packages/matplotlib/mpl-data/fonts/ttf/cmmi10.ttf
trying fontname /usr/lib/python2.5/site-packages/matplotlib/mpl-data/fonts/ttf/VeraSeBd.ttf
trying fontname /usr/lib/python2.5/site-packages/matplotlib/mpl-data/fonts/ttf/cmsy10.ttf
trying fontname /usr/lib/python2.5/site-packages/matplotlib/mpl-data/fonts/ttf/VeraIt.ttf
trying fontname /usr/lib/python2.5/site-packages/matplotlib/mpl-data/fonts/ttf/VeraMoBd.ttf
trying fontname /usr/lib/python2.5/site-packages/matplotlib/mpl-data/fonts/ttf/cmex10.ttf
trying fontname /usr/lib/python2.5/site-packages/matplotlib/mpl-data/fonts/ttf/cmtt10.ttf
trying fontname /usr/lib/python2.5/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
loaded ttfcache file /home/riveraca/.matplotlib/ttffont.cache
backend GTKAgg version 2.10.3
PROTON DOSE SPECTRUM
(0.0, 0.0, 0.0, 616.0, 24.0, 616.0) <type 'tuple'> <type 'float'>
(0.0, 0.0, 0.0, 28869.0, 169.0, 28869.0) <type 'tuple'> <type 'float'>
(0.0, 0.0, 0.0, 13900.0, 117.0, 13900.0) <type 'tuple'> <type 'float'>
(0.0, 0.0, 0.0, 6896.0, 83.0, 6896.0) <type 'tuple'> <type 'float'>
(0.0, 0.0, 0.0, 3749.0, 61.0, 3749.0) <type 'tuple'> <type 'float'>
  findfont failed Bitstream Vera Serif, New Century Schoolbook, Century Schoolbook L, Utopia, ITC Bookman, Bookman, Nimbus Roman No9 L, Times New Roman, Times, Palatino, Charter, serif
Could not match Bitstream Vera Serif, New Century Schoolbook, Century Schoolbook L, Utopia, ITC Bookman, Bookman, Nimbus Roman No9 L, Times New Roman, Times, Palatino, Charter, serif, normal, normal. Returning /usr/lib/python2.5/site-packages/matplotlib/mpl-data/fonts/ttf/Vera.ttf
-----------

Florian Koelling recently reported a problem that sounded very similar
under the heading "mad interference between matplotlib and openbabel".
Apparently some pylab import is doing something funky with some third
party libs.

Could you test just the numpy imports to see if that makes a
difference. Ie, instead of importing pylab before your module code,
do the following:

import numpy
import numpy.fft
importnumpy.random
import numpy.linalg

and let us know if you see similar problems.

JDH

I've tried with just these imports and there's no problem with that, everything runs ok, it's when I add the pylab imports when everything goes wrong. I've tried with these three posibilities and the result is always the same:

import pylab

from pylab import *

from pylab import figure, show, bar

AR

your numpy and matplotlib versions are pretty old. Any chance you can
upgrade to numpy 1.1 and matplotlib 98.1?

JDH

···

On Tue, Jul 15, 2008 at 2:37 AM, Angela Rivera Campos <riveraca@...2087...> wrote:

matplotlib version 0.90.1
numerix numpy 1.0.3

John Hunter escribió:

···

On Tue, Jul 15, 2008 at 2:37 AM, Angela Rivera Campos <riveraca@...2097....> wrote:

matplotlib version 0.90.1
numerix numpy 1.0.3

your numpy and matplotlib versions are pretty old. Any chance you can
upgrade to numpy 1.1 and matplotlib 98.1?

JDH

OK. I've been upgrading my versions and the output is still the same, no proper floating managing. I'm using openSUSE 10.2 and I've installed the numpy and scipy rmps from the repositories suggested on the webpage and compiled matplotlib from source. This is the output for python verbose mode:

-----------------------
$HOME=/home/myhome
CONFIGDIR=/home/myhome/.matplotlib
matplotlib data path /usr/local/lib/python2.5/site-packages/matplotlib/mpl-data
loaded rc file /home/myhome/.matplotlib/matplotlibrc
matplotlib version 0.98.1
verbose.level debug
interactive is False
units is True
platform is linux2
loaded modules: ['pylab', '_bisect', 'numpy.ma.types', 'numpy.core.info', 'numpy.testing.shlex', 'matplotlib.errno', 'random', 'heapq', 'numpy.core.defchararray', 'distutils.re', 'numpy.lib.bz2', 'numpy.lib.inspect', 'xml.sax.os', 'numpy.lib.getlimits', 'ctypes._endian', 'encodings.encodings', 'pkgutil', 'numpy.core.numerictypes', 'numpy.testing.sys', 'numpy.random.mtrand', 'xml', 'numpy.fft.types', 'numpy.ma.operator', 'numpy.ma.cPickle', 'struct', 'numpy.random.info', 'tempfile', 'mmap', 'pprint', 'numpy.linalg', 'numpy.testing.operator', 'matplotlib', 'imp', 'compiler.sys', 'collections', 'numpy.core.umath', 'numpy.lib.pkgutil', 'unittest', 'md5', 'matplotlib.cbook', 'compiler.ast', 'numpy.ma.sys', 'zipimport', 'string', 'numpy.testing.os', 'matplotlib.locale', 'numpy.lib.arraysetops', 'numpy.testing.unittest', 'numpy.lib.math', 'encodings.utf_8', 'matplotlib.__future__', 'pytz.tzinfo', 'numpy.ctypeslib', 'numpy.testing.re', 'itertools', 'numpy.version', 'numpy.lib.re', 'compiler.misc', 'ctypes.os', 'compiler.token', 'numpy.core.os', 'compiler', 'numpy.lib.type_check', 'httplib', 'xml.sax.sys', 'matplotlib.os', 'xml._xmlplus', 'bisect', 'signal', 'compiler.consts', 'numpy.lib._datasource', 'pydoc', 'numpy.ma.extras', 'token', 'numpy.fft.fftpack_lite', 'encodings.types', 'shlex', 'numpy.core.multiarray', 'matplotlib.pytz', 'numpy.__builtin__', 'dis', 'xml.sax.saxexts', 'cStringIO', 'zlib', 'xml.sax.saxutils', 'numpy.numpy', 'matplotlib.StringIO', 'locale', 'numpy.add_newdocs', 'distutils.sysconfig', 'xml.sax.urlparse', 'numpy.random.numpy', 'compiler.transformer', 'xml.sax.saxlib', 'compiler.struct', 'compiler.parser', 'numpy.lib.sys', 'encodings', 'compiler.symbol', 'numpy.ma.itertools', 'StringIO', 'dateutil', 'numpy.lib.io', '__future__', 'matplotlib.colors', 'numpy.imp', 'matplotlib.warnings', 'rfc822', 'matplotlib.string', 'numpy.lib.numpy', 'matplotlib.sys', 're', 'numpy.lib._compiled_base', 'matplotlib.numpy', 'numpy.core.mmap', 'new', 'numpy.lib.struct', 'glob', 'math', 'numpy.fft.helper', 'fcntl', 'numpy.ma.warnings', 'compiler.imp', 'matplotlib.pyparsing', 'distutils', 'UserDict', 'inspect', 'distutils.os', '_ctypes', 'urllib2', 'exceptions', 'numpy.lib.info', 'numpy.testing', 'numpy.testing.glob', 'numpy.lib.warnings', 'ctypes.struct', 'numpy.core.sys', 'numpy.core._sort', 'numpy.os', 'compiler.visitor', 'numpy.testing.difflib', 'matplotlib.sre_constants', 'numpy.lib.shutil', 'thread', 'numpy.lib.ufunclike', 'numpy.core.memmap', 'traceback', 'xml.sax.types', 'numpy.testing.warnings', 'xml.sax.sax2exts', 'weakref', 'numpy.core._internal', 'numpy.fft.fftpack', 'opcode', 'numpy.testing.imp', 'numpy.linalg.lapack_lite', 'ctypes', 'distutils.sys', 'os', 'marshal', 'base64', 'numpy.core.string', 'matplotlib.copy', 'compiler.cStringIO', 'matplotlib.traceback', '_sre', 'numpy.lib.gzip', 'codecs', 'numpy.random', 'numpy.linalg.numpy', '__builtin__', 'numpy.lib.twodim_base', 'numpy.ma.core', 'matplotlib.re', 'numpy.core.cPickle', 'operator', 'numpy.testing.parametric', 'sre_constants', 'distutils.string', 'ctypes._ctypes', '_heapq', 'ctypes.sys', 'matplotlib.datetime', 'posixpath', 'numpy.lib.financial', 'numpy.testing.types', 'errno', '_socket', 'binascii', 'numpy.lib.compiler', 'numpy.core.arrayprint', 'datetime', 'compiler.os', 'matplotlib.md5', 'types', 'pytz.sys', 'tokenize', 'xml.sax.handler', 'xml.sax.xmlreader', 'numpy.core.numpy', 'numpy', 'numpy.lib.urlparse', 'matplotlib.dateutil', 'numpy.core.defmatrix', 'compiler.compiler', 'cPickle', 'matplotlib.xml', 'xml.sax.string', '_codecs', '_locale', 'numpy.__config__', 'numpy.lib.types', 'pytz', 'compiler.syntax', 'compiler.copy_reg', 'numpy.ma.numpy', 'copy', 'numpy.core.re', '_struct', '_types', 'numpy.core.fromnumeric', 'hashlib', 'compiler.future', 'numpy.core.copy_reg', 'numpy.lib.scimath', 'numpy.fft', 'numpy.lib', 'compiler.dis', 'posix', 'encodings.aliases', 'numpy.lib.function_base', 'fnmatch', 'sre_parse', 'pytz.bisect', 'matplotlib.tempfile', 'numpy.lib.tempfile', 'numpy.core.ctypes', 'xml.sys', 'mimetools', 'distutils.distutils', '_xmlplus', 'copy_reg', 'sre_compile', 'xml.sax', 'numpy.core.scalarmath', '_hashlib', '_random', 'parser', 'site', 'numpy.lib.polynomial', 'urllib', 'numpy._import_tools', 'numpy.glob', 'xml.sax.urllib2', 'numpy.lib.time', '__main__', 'numpy.fft.info', 'numpy.core.records', 'shutil', 'numpy.lib.cPickle', 'numpy.sys', 'matplotlib.weakref', '_weakref', 'numpy.lib.pydoc', 'numpy.lib.urllib2', 'numpy.testing.traceback', 'strop', 'compiler.pycodegen', 'numpy.core.numeric', 'numpy.linalg.info', 'encodings.codecs', 'pytz.datetime', 'numpy.ctypes', 'matplotlib.matplotlib', 'numpy.core', 'numpy.testing.info', 'matplotlib.rcsetup', 'matplotlib.time', 'pytz.sets', '_ssl', 'xml.sax._exceptions', 'xml.sax.codecs', 'stat', 'compiler.new', 'compiler.pyassem', 'numpy.lib.index_tricks', 'numpy.testing.utils', 'warnings', 'numpy.lib.utils', 'symbol', 'numpy.lib.shape_base', 'numpy.core.types', 'numpy.fft.numpy', 'repr', 'sys', 'numpy.core.warnings', 'socket', 'compiler.types', 'numpy.core.__builtin__', 'ctypes.ctypes', 'numpy.lib.format', 'numpy.lib.os', 'numpy.ma', 'matplotlib.fontconfig_pattern', 'os.path', 'bz2', 'numpy.lib.pprint', 'compiler.symbols', 'sets', 'matplotlib.distutils', 'numpy.core.cStringIO', 'numpy.testing.numpytest', 'difflib', 'distutils.errors', 'urlparse', 'linecache', 'matplotlib.shutil', 'numpy.lib.cStringIO', 'time', 'gzip', 'numpy.lib.machar', 'compiler.marshal', 'numpy.linalg.linalg', 'numpy.testing.numpy']
Using fontManager instance from /home/myhome/.matplotlib/fontManager.cache
numerix numpy 1.1.0
backend GTKAgg version 2.10.3
PROTON DOSE SPECTRUM
(0.0, 0.0, 0.0, 616.0, 24.0, 616.0) <type 'tuple'> <type 'float'>
(0.0, 0.0, 0.0, 28869.0, 169.0, 28869.0) <type 'tuple'> <type 'float'>
(0.0, 0.0, 0.0, 13900.0, 117.0, 13900.0) <type 'tuple'> <type 'float'>
(0.0, 0.0, 0.0, 6896.0, 83.0, 6896.0) <type 'tuple'> <type 'float'>
(0.0, 0.0, 0.0, 3749.0, 61.0, 3749.0) <type 'tuple'> <type 'float'>
-----------------------

Now I'm using a work around managing the data in a different module, so the pylab imports are done after reading the data. But, still, this issue is puzzling me.

Thanks,

AR

Hi, again

I've trying to install everything, from the begining on another machine, this one's running openSUSE 10.3. So I've installed the latest versions of numpy, scipy and matplotlib and I've discovered something new which also happens in the first machine, the one with openSUSE 10.2. The first time I imported pylab this is what I got:

···

---------------------------------
>>> from pylab import *
/usr/lib/python2.5/site-packages/gtk-2.0/gtk/__init__.py:69: GtkWarning: could not open display
   warnings.warn(str(e), _gtk.Warning)
/usr/local/lib/python2.5/site-packages/matplotlib/backends/backend_gtk.py:40: GtkWarning: gdk_cursor_new_for_display: assertion `GDK_IS_DISPLAY (display)' failed
   cursors.MOVE : gdk.Cursor(gdk.FLEUR),
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File "/usr/local/lib/python2.5/site-packages/pylab.py", line 1, in <module>
     from matplotlib.pylab import *
   File "/usr/local/lib/python2.5/site-packages/matplotlib/pylab.py", line 247, in <module>
     from matplotlib.pyplot import *
   File "/usr/local/lib/python2.5/site-packages/matplotlib/pyplot.py", line 39, in <module>
     new_figure_manager, draw_if_interactive, show = pylab_setup()
   File "/usr/local/lib/python2.5/site-packages/matplotlib/backends/__init__.py", line 20, in pylab_setup
     globals(),locals(),[backend_name])
   File "/usr/local/lib/python2.5/site-packages/matplotlib/backends/backend_gtkagg.py", line 10, in <module>
     from matplotlib.backends.backend_gtk import gtk, FigureManagerGTK, FigureCanvasGTK,\
   File "/usr/local/lib/python2.5/site-packages/matplotlib/backends/backend_gtk.py", line 40, in <module>
     cursors.MOVE : gdk.Cursor(gdk.FLEUR),
RuntimeError: could not create GdkCursor object
---------------------------------

So googling a bit, I've found that to avoid this error an option would be to add, before the pylab import, the following:

>>> import matplotlib
>>> matplotlib.use('Agg')

This way the results floating problem disappears and I've got the correct tuples, though now I can't make my script show the figure I'm trying to plot. Is this related with matplotlibrc configuration? I haven't modified this file and the only lines that are not commented are

backend : GTKAgg
numerix : numpy # numpy, Numeric or numarray

Running my script with and without these lines with --verbose-debug, I've found that when they're written I get: backend agg version v2.2
and when they are not: backend GTKAgg version 2.10.6

I've also checked the packages installed but all the requirements seem to be OK.

Hope, this helps.

AR

Hi, again

I've trying to install everything, from the begining on another machine,
this one's running openSUSE 10.3. So I've installed the latest versions of
numpy, scipy and matplotlib and I've discovered something new which also
happens in the first machine, the one with openSUSE 10.2. The first time I
imported pylab this is what I got:

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

from pylab import *

/usr/lib/python2.5/site-packages/gtk-2.0/gtk/__init__.py:69: GtkWarning:
could not open display

If you cannot open the display, most likely it is because either you
are running as root (bad, bad) or you are running over a remot
connection (ssh) and do not have X11 forwarding properly enabled or
configures. If you want to use mpl with an interactive window, you
will need to have access to the display. The fact that you see this
error only on the first time you import pylab is typical of exceptions
that are thrown at module import time -- python only tries to import
once so you see the exception only once. To solve this, trying
running as a normal user rather than root or sudo, and if you are on a
remote machine, try using ssh -X to enable X11 forwarding. We will
need to know more about exactly what you are doing to help.

So googling a bit, I've found that to avoid this error an option would be to
add, before the pylab import, the following:

import matplotlib
matplotlib.use('Agg')

This way the results floating problem disappears and I've got the correct
tuples, though now I can't make my script show the figure I'm trying to
plot. Is this related with matplotlibrc configuration? I haven't modified
this file and the only lines that are not commented are

backend : GTKAgg
numerix : numpy # numpy, Numeric or numarray

Running my script with and without these lines with --verbose-debug, I've
found that when they're written I get: backend agg version v2.2
and when they are not: backend GTKAgg version 2.10.6

This isn't a problem with matplotlib, but with the connection to the
display as I mentioned above.
Hopefully once you get the display problem sorted out, all will be
well. Let us know.

JDH

···

On Wed, Jul 16, 2008 at 6:12 AM, Angela Rivera Campos <riveraca@...2087...> wrote:

John Hunter wrote:

Hi, again

I've trying to install everything, from the begining on another machine,
this one's running openSUSE 10.3. So I've installed the latest versions of
numpy, scipy and matplotlib and I've discovered something new which also
happens in the first machine, the one with openSUSE 10.2. The first time I
imported pylab this is what I got:

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

from pylab import *

/usr/lib/python2.5/site-packages/gtk-2.0/gtk/__init__.py:69: GtkWarning:
could not open display

If you cannot open the display, most likely it is because either you
are running as root (bad, bad) or you are running over a remot
connection (ssh) and do not have X11 forwarding properly enabled or
configures. If you want to use mpl with an interactive window, you
will need to have access to the display. The fact that you see this
error only on the first time you import pylab is typical of exceptions
that are thrown at module import time -- python only tries to import
once so you see the exception only once. To solve this, trying
running as a normal user rather than root or sudo, and if you are on a
remote machine, try using ssh -X to enable X11 forwarding. We will
need to know more about exactly what you are doing to help.

For remote access you also need to allow the remote machine to access the display via "xhost +name" on the local machine.

···

On Wed, Jul 16, 2008 at 6:12 AM, Angela Rivera Campos <riveraca@...2087...> wrote:

So googling a bit, I've found that to avoid this error an option would be to
add, before the pylab import, the following:

import matplotlib
matplotlib.use('Agg')

This way the results floating problem disappears and I've got the correct
tuples, though now I can't make my script show the figure I'm trying to
plot. Is this related with matplotlibrc configuration? I haven't modified
this file and the only lines that are not commented are

backend : GTKAgg
numerix : numpy # numpy, Numeric or numarray

Running my script with and without these lines with --verbose-debug, I've
found that when they're written I get: backend agg version v2.2
and when they are not: backend GTKAgg version 2.10.6

This isn't a problem with matplotlib, but with the connection to the
display as I mentioned above.
Hopefully once you get the display problem sorted out, all will be
well. Let us know.

JDH

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

If you cannot open the display, most likely it is because either you
are running as root (bad, bad) or you are running over a remot
connection (ssh) and do not have X11 forwarding properly enabled or
configures. If you want to use mpl with an interactive window, you
will need to have access to the display. The fact that you see this
error only on the first time you import pylab is typical of exceptions
that are thrown at module import time -- python only tries to import
once so you see the exception only once. To solve this, trying
running as a normal user rather than root or sudo, and if you are on a
remote machine, try using ssh -X to enable X11 forwarding. We will
need to know more about exactly what you are doing to help.

For remote access you also need to allow the remote machine to access the display via "xhost +name" on the local machine.

Well, I can assure you that I am neither working as root, I might be a newbie to matplotlib but not to linux, nor have any problem with the display. This problem is happening in both machines, remote (ssh -X, for sure, I've tested several times) and local, so no ssh conection. Anyway, I'm going to test a few more things and will let you know what happens.

AR

Well, I can assure you that I am neither working as root, I might be a
newbie to matplotlib but not to linux, nor have any problem with the
display. This problem is happening in both machines, remote (ssh -X, for
sure, I've tested several times) and local, so no ssh conection. Anyway,
I'm going to test a few more things and will let you know what happens.

Very strange indeed -- the error clear indicates you cannot connect to
the display. You should see the same in the same nvironment if you
simply

import gtk

as the first line. Do you?

JDH

···

On Thu, Jul 17, 2008 at 1:22 AM, Angela Rivera Campos <riveraca@...2087...> wrote:

Hello again,

I'm really sorry for not having written for such a long time, but I've been on vacation.

I've been trying to figure out what is happening with the import pylab thing and why it makes the rounding to my data. I've found that the problem might be related with some conflict between two different imports.

To read my data from the files, I'm using a set of libraries that are produced by a swig wrapper to the C++ original libraries and somewhere through the handling of the data it collides with the pylab importing. Up till now these libraries have worked just fine and have given me no problem.

Anyway, for skipping the problem and make everything work I've changed the import of the pylab module to the function where it is being used, I know it's ugly, and I don't like it but as it works I think I'll leave it like that and make a little research on the subject in my spare time.

Thanks a lot for you time and attention.

ARC