2D plotting problem

1 view
Skip to first unread message

Petr Muzikar

unread,
Jan 23, 2008, 6:59:21 AM1/23/08
to sage-newbie
Hello.
I have a problem with 2D plotting in SAGE version 2.10 on Ubuntu 7.10
32bit. If I type

show(plot(sin(x), -5, 5))

SAGE complains:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/petr/.sage/sage_notebook/worksheets/admin/2/code/3.py",
line 4, in <module>
show(plot(sin(x), -Integer(5), Integer(5)))
File "/home/petr/Instalace/sage-2.10-ubuntu32-i686-Linux/local/lib/
python2.5/site-packages/sympy/plotting/", line 1, in <module>

File "/home/petr/Instalace/sage-2.10-ubuntu32-i686-Linux/local/lib/
python2.5/site-packages/sage/misc/functional.py", line 888, in show
return x.show(*args, **kwds)
File "/home/petr/Instalace/sage-2.10-ubuntu32-i686-Linux/local/lib/
python2.5/site-packages/sage/plot/plot.py", line 721, in show
dpi=dpi, axes=axes, axes_label=axes_label,frame=frame)
File "/home/petr/Instalace/sage-2.10-ubuntu32-i686-Linux/local/lib/
python2.5/site-packages/sage/plot/plot.py", line 792, in save
from matplotlib.figure import Figure
File "/home/petr/Instalace/sage-2.10-ubuntu32-i686-Linux/local/lib/
python2.5/site-packages/matplotlib/figure.py", line 10, in <module>
from axes import Axes, Subplot, PolarSubplot, PolarAxes
File "/home/petr/Instalace/sage-2.10-ubuntu32-i686-Linux/local/lib/
python2.5/site-packages/matplotlib/axes.py", line 13, in <module>
from matplotlib import axis as maxis
File "/home/petr/Instalace/sage-2.10-ubuntu32-i686-Linux/local/lib/
python2.5/site-packages/matplotlib/axis.py", line 20, in <module>
from font_manager import FontProperties
File "/home/petr/Instalace/sage-2.10-ubuntu32-i686-Linux/local/lib/
python2.5/site-packages/matplotlib/font_manager.py", line 1129, in
<module>
_rebuild()
File "/home/petr/Instalace/sage-2.10-ubuntu32-i686-Linux/local/lib/
python2.5/site-packages/matplotlib/font_manager.py", line 1120, in
_rebuild
fontManager = FontManager()
File "/home/petr/Instalace/sage-2.10-ubuntu32-i686-Linux/local/lib/
python2.5/site-packages/matplotlib/font_manager.py", line 910, in
__init__
self.afmdict = createFontDict(self.afmfiles, fontext='afm')
File "/home/petr/Instalace/sage-2.10-ubuntu32-i686-Linux/local/lib/
python2.5/site-packages/matplotlib/font_manager.py", line 509, in
createFontDict
font = afm.AFM(fh)
File "/home/petr/Instalace/sage-2.10-ubuntu32-i686-Linux/local/lib/
python2.5/site-packages/matplotlib/afm.py", line 294, in __init__
parse_afm(fh)
File "/home/petr/Instalace/sage-2.10-ubuntu32-i686-Linux/local/lib/
python2.5/site-packages/matplotlib/afm.py", line 282, in parse_afm
dcmetrics_ascii, dcmetrics_name = _parse_char_metrics(fh)
File "/home/petr/Instalace/sage-2.10-ubuntu32-i686-Linux/local/lib/
python2.5/site-packages/matplotlib/afm.py", line 167, in
_parse_char_metrics
bbox = _to_list_of_ints(vals[3][2:])
File "/home/petr/Instalace/sage-2.10-ubuntu32-i686-Linux/local/lib/
python2.5/site-packages/matplotlib/afm.py", line 47, in
_to_list_of_ints
return [_to_int(val) for val in s.split()]
ValueError: invalid literal for int() with base 10: '691.858'

and no plot appears. I tried versions 2.9.* (binary as well as source)
with the same result. However, versions 2.8.15 and older work fine.

Could you please help me to solve this problem? Thank you.

Petr Muzikar

William Stein

unread,
Jan 23, 2008, 8:32:34 AM1/23/08
to sage-...@googlegroups.com

In Sage 2.10 for me the above works fine. Maybe you defined x to
be something and forgot? Could you try from a fresh Sage session?

Also, could you try

sage: show(plot(math.sin, -5, 5))

--
William Stein
Associate Professor of Mathematics
University of Washington
http://wstein.org

Petr Muzikar

unread,
Jan 23, 2008, 9:35:33 AM1/23/08
to sage-newbie
On 23 Led, 14:32, "William Stein" <wst...@gmail.com> wrote:

> In Sage 2.10 for me the above works fine. Maybe you defined x to
> be something and forgot? Could you try from a fresh Sage session?
>
> Also, could you try
>
> sage: show(plot(math.sin, -5, 5))

So I have created a new worksheet and tried

var('x')
show(plot(sin(x), -5, 5))

and

show(plot(math.sin, -5, 5))

but the exception still occurs. The two error messages differ only in

< File "/home/petr/.sage/sage_notebook/worksheets/admin/3/code/
1.py", line 5, in <module>
< show(plot(sin(x), -Integer(5), Integer(5)))
---
> File "/home/petr/.sage/sage_notebook/worksheets/admin/3/code/2.py", line 4, in <module>
> show(plot(math.sin, -Integer(5), Integer(5)))

Here are the two files: 1.py

from __future__ import with_statement
print " b0"
os.chdir("/home/petr/.sage/sage_notebook/worksheets/admin/3/cells/0")
var('x')
exec compile(ur'show(plot(sin(x), -Integer(5), Integer(5)))' + '\n',
'', 'single')

print " e0"

and 2.py

from __future__ import with_statement
print " b1"
os.chdir("/home/petr/.sage/sage_notebook/worksheets/admin/3/cells/1")
exec compile(ur'show(plot(math.sin, -Integer(5), Integer(5)))' + '\n',
'', 'single')

print " e1"

SAGE command line gives the same error while executing
show(plot(math.sin, -5, 5)).

Thank you for any answer.

Petr Muzikar

William Stein

unread,
Jan 23, 2008, 9:48:32 AM1/23/08
to sage-...@googlegroups.com
On Jan 23, 2008 3:59 AM, Petr Muzikar <muzika...@volny.cz> wrote:
>

Just out of curiosity:

(1) What happens when you try at https://www.sagenb.org?

(2) Have you considered building from source? It's not as
hard as it sounds. Just get the newest source tarball from
http://sagemath.org/dist/src/, make sure you have these Ubuntu
packages installed
gcc, g++, make, m4, perl, ranlib
then do
tar xvf sage-2.10.tar
cd sage-2.10
make
and wait 3 hours (do it when you're about to leave or something).
That's it.

-- William

Petr Muzikar

unread,
Jan 23, 2008, 10:42:04 AM1/23/08
to sage-newbie
> (1) What happens when you try athttps://www.sagenb.org?
It runs perfectly.

> (2) Have you considered building from source?
I built version 2.10 before I asked here. It has the same problem
although the file install.log ends with
SAGE build/upgrade complete! But I haven't read the whole 14MB-
file :-)

Petr Muzikar

Petr Muzikar

unread,
Jan 25, 2008, 6:18:57 PM1/25/08
to sage-newbie
Hello.

I have built SAGE versions 2.9.2, 2.9.1.1 and 2.9.1. In all of them I
have the same problem: any 2D plot causes an error message and no plot
appears. On the other hand, 3D plots are OK. So I will keep using the
version 2.8.15 on Linux. On Windows I have no problem.

Professor Stein, I thank you for your answers and I wish you will
success in developing SAGE.

Petr Muzikar
(Petr Muzik\'{a}\v{r})

PS I study physics at the Charles University in Prague, Czech
Republic, like Ondrej Certik.

William Stein

unread,
Jan 25, 2008, 6:22:59 PM1/25/08
to sage-...@googlegroups.com
On Jan 25, 2008 3:18 PM, Petr Muzikar <muzika...@volny.cz> wrote:
>
> Hello.
>
> I have built SAGE versions 2.9.2, 2.9.1.1 and 2.9.1. In all of them I
> have the same problem: any 2D plot causes an error message and no plot
> appears. On the other hand, 3D plots are OK. So I will keep using the
> version 2.8.15 on Linux. On Windows I have no problem.
>
> Professor Stein, I thank you for your answers and I wish you will
> success in developing SAGE.

This is undoubtedly some sort of serious problem with the interaction
between matplotlib and something systemwide on your computer maybe
having to do with fonts or languages (?). Some things to try:

(1) Install the _old_ version of matplotlib. Some things won't look perfect,
but it will be way better than nothing, and give us some helpful debugging
information. Do this by extracting the old source tarball (that
worked for you),
and doing
sage -f matplotlib-0.91.1.p2.spkg
where 0.91.1.p2 is replaced by the version that used to work for you.

(2) Get Ondrej Certik to sit down at your computer and try some debugging of
matplotlib :-).


> Petr Muzikar
> (Petr Muzik\'{a}\v{r})
>
> PS I study physics at the Charles University in Prague, Czech
> Republic, like Ondrej Certik.
>
> >
>

--

mabshoff

unread,
Jan 25, 2008, 6:25:41 PM1/25/08
to sage-newbie


On Jan 26, 12:22 am, "William Stein" <wst...@gmail.com> wrote:
> On Jan 25, 2008 3:18 PM, Petr Muzikar <muzikar.p...@volny.cz> wrote:
>
>
>
> > Hello.
>
> > I have built SAGE versions 2.9.2, 2.9.1.1 and 2.9.1. In all of them I
> > have the same problem: any 2D plot causes an error message and no plot
> > appears. On the other hand, 3D plots are OK. So I will keep using the
> > version 2.8.15 on Linux. On Windows I have no problem.
>
> > Professor Stein, I thank you for your answers and I wish you will
> > success in developing SAGE.
>
> This is undoubtedly some sort of serious problem with the interaction
> between matplotlib and something systemwide on your computer maybe
> having to do with fonts or languages (?). Some things to try:
>
> (1) Install the _old_ version of matplotlib. Some things won't look perfect,
> but it will be way better than nothing, and give us some helpful debugging
> information. Do this by extracting the old source tarball (that
> worked for you),
> and doing
> sage -f matplotlib-0.91.1.p2.spkg
> where 0.91.1.p2 is replaced by the version that used to work for you.
>
> (2) Get Ondrej Certik to sit down at your computer and try some debugging of
> matplotlib :-).

We also just merged

#1604: William Stein: more locale problems with python exposed by
matplotlib

which will be in 2.10.1. Maybe that will fix the issue. The patch
itself isn't trivial to apply, but it isn't too hard either.

What is your $LOCAL, i.e. the output from "echo $LOCAL"?

Cheers,

Michael

Petr Muzikar

unread,
Feb 1, 2008, 10:55:02 AM2/1/08
to sage-newbie
> (1) Install the _old_ version of matplotlib. Some things won't look perfect,
> but it will be way better than nothing, and give us some helpful debugging
> information. Do this by extracting the old source tarball (that
> worked for you),
> and doing
> sage -f matplotlib-0.91.1.p2.spkg
> where 0.91.1.p2 is replaced by the version that used to work for you.

My fully functional SAGE 2.8.15 contains matplotlib-0.90.0.p5. So I
copied it into my sage-2.10/spkg/standard directory and in sage-2.10
direcrory I did

./sage -f matplotlib-0.90.0.p5.spkg

Here you can see all warnings:

cc1plus: warning: command line option "-Wstrict-prototypes" is valid
for Ada/C/ObjC but not for C++
agg23/include/agg_conv_curve.h:123: warning: 'end_y' may be used
uninitialized in this function
agg23/include/agg_conv_curve.h:122: warning: 'end_x' may be used
uninitialized in this function
agg23/include/agg_conv_curve.h:121: warning: 'ct2_y' may be used
uninitialized in this function
agg23/include/agg_conv_curve.h:120: warning: 'ct2_x' may be used
uninitialized in this function
./CXX/Extensions.hxx:477: warning: right-hand operand of comma has no
effect
lib/matplotlib/enthought/traits/ctraits.c:3798: warning: 'name' may be
used uninitialized in this function
lib/matplotlib/enthought/traits/ctraits.c:3797: warning: 'value' may
be used uninitialized in this function
lib/matplotlib/enthought/traits/ctraits.c:1067: warning: 'result' may
be used uninitialized in this function
src/_ns_cntr.c:1365: warning: unused variable 'point'
src/_ns_cntr.c:1328: warning: 'build_cntr_list_v' defined but not used

Now I have both versions of matplotlib installed. If I do

var('x')
show(plot(sin(x),-5,5))

SAGE prints:

Graphics object consisting of 1 graphics primitive

and doesn't show any plot. Did I something wrong?

I also noticed that in files 1.py and 2.py mentioned above there is a
^A character (displayed in GVIM). Here you can see a strange square.

from __future__ import with_statement
print " b0"
os.chdir("/home/petr/.sage/sage_notebook/worksheets/admin/3/cells/0")
var('x')
exec compile(ur'show(plot(sin(x), -Integer(5), Integer(5)))' + '\n',
'', 'single')

print " e0"

> What is your $LOCAL, i.e. the output from "echo $LOCAL"?

echo $LOCAL prints nothing.

My Ubuntu "speaks" czech language.

Thank you for your assistance.
Petr Muzikar

mabshoff

unread,
Feb 1, 2008, 8:02:07 PM2/1/08
to sage-newbie


On Feb 1, 4:55 pm, Petr Muzikar <muzikar.p...@volny.cz> wrote:
> > (1) Install the _old_ version of matplotlib. Some things won't look perfect,
> > but it will be way better than nothing, and give us some helpful debugging
> > information. Do this by extracting the old source tarball (that
> > worked for you),
> > and doing
> > sage -f matplotlib-0.91.1.p2.spkg
> > where 0.91.1.p2 is replaced by the version that used to work for you.

Hi Petr,

> My fully functional SAGE 2.8.15 contains matplotlib-0.90.0.p5. So I
> copied it into my sage-2.10/spkg/standard directory and in sage-2.10
> direcrory I did
>
> ./sage -f matplotlib-0.90.0.p5.spkg

Sage 2.10.1 will contain a LOCAL fix that will hopefully also fix your
issues.

> Here you can see all warnings:
>
> cc1plus: warning: command line option "-Wstrict-prototypes" is valid
> for Ada/C/ObjC but not for C++
> agg23/include/agg_conv_curve.h:123: warning: 'end_y' may be used
> uninitialized in this function
> agg23/include/agg_conv_curve.h:122: warning: 'end_x' may be used
> uninitialized in this function
> agg23/include/agg_conv_curve.h:121: warning: 'ct2_y' may be used
> uninitialized in this function
> agg23/include/agg_conv_curve.h:120: warning: 'ct2_x' may be used
> uninitialized in this function
> ./CXX/Extensions.hxx:477: warning: right-hand operand of comma has no
> effect
> lib/matplotlib/enthought/traits/ctraits.c:3798: warning: 'name' may be
> used uninitialized in this function
> lib/matplotlib/enthought/traits/ctraits.c:3797: warning: 'value' may
> be used uninitialized in this function
> lib/matplotlib/enthought/traits/ctraits.c:1067: warning: 'result' may
> be used uninitialized in this function
> src/_ns_cntr.c:1365: warning: unused variable 'point'
> src/_ns_cntr.c:1328: warning: 'build_cntr_list_v' defined but not used

Those can be safely ignored.

> Now I have both versions of matplotlib installed. If I do

You should only have one installed.

> var('x')
> show(plot(sin(x),-5,5))
>
> SAGE prints:
>
> Graphics object consisting of 1 graphics primitive
>
> and doesn't show any plot. Did I something wrong?
>
> I also noticed that in files 1.py and 2.py mentioned above there is a
> ^A character (displayed in GVIM). Here you can see a strange square.

That would potentially point to the problem.

> from __future__ import with_statement
> print " b0"
> os.chdir("/home/petr/.sage/sage_notebook/worksheets/admin/3/cells/0")
> var('x')
> exec compile(ur'show(plot(sin(x), -Integer(5), Integer(5)))' + '\n',
> '', 'single')
>
> print " e0"
>
> > What is your $LOCAL, i.e. the output from "echo $LOCAL"?
>
> echo $LOCAL prints nothing.
>
> My Ubuntu "speaks" czech language.

Ok. We need somebody who can reproduce this in order to be able to
debug this. Hopefully 2.10.1 will fix the problem.

Does switching to an English local fix the problem?

> Thank you for your assistance.
> Petr Muzikar

Cheers,

Michael

Petr Muzikar

unread,
Feb 3, 2008, 4:33:36 PM2/3/08
to sage-newbie
In my previous message the ^A's disappeared so you could not see them.
If I open the file 1.py in GVIM, I see

from __future__ import with_statement
print "^Ab0"
os.chdir("/home/petr/.sage/sage_notebook/worksheets/admin/3/cells/0")
var('x')
exec compile(ur'show(plot(sin(x), -Integer(5), Integer(5)))' + '\n',
'', 'single')

print "^Ae0"

where ^A's are blue.

> Does switching to an English local fix the problem?

I switched the language before logging in. I don't know if I must
configure something else. Everything in my Ubuntu seems to be in
English now.

echo $LANG

gives en_US.UTF-8 but

echo $LOCAL

prints nothing again. I rebuilt SAGE 2.10 but unfortunately my problem
persists.

How could I uninstall the new version of matplotlib and replace it
with the old one? I want to try prof. Stein's suggestion. I was able
to install both versions but it could cause a conflict.

I also built matplotlib 0.91.2 in python (not in SAGE) and after doing
(in an English localization)

python gradient_bar.py

appeared a similar warning

Traceback (most recent call last):
File "gradient_bar.py", line 1, in <module>
from matplotlib.pyplot import figure, show, cm
File "/usr/lib/python2.5/site-packages/matplotlib/pyplot.py", line
6, in <module>
from matplotlib.figure import Figure, figaspect
File "/usr/lib/python2.5/site-packages/matplotlib/figure.py", line
11, in <module>
from axes import Axes, Subplot, PolarSubplot, PolarAxes
File "/usr/lib/python2.5/site-packages/matplotlib/axes.py", line 13,
in <module>
from matplotlib import axis as maxis
File "/usr/lib/python2.5/site-packages/matplotlib/axis.py", line 20,
in <module>
from font_manager import FontProperties
File "/usr/lib/python2.5/site-packages/matplotlib/font_manager.py",
line 1132, in <module>
_rebuild()
File "/usr/lib/python2.5/site-packages/matplotlib/font_manager.py",
line 1123, in _rebuild
fontManager = FontManager()
File "/usr/lib/python2.5/site-packages/matplotlib/font_manager.py",
line 913, in __init__
self.afmdict = createFontDict(self.afmfiles, fontext='afm')
File "/usr/lib/python2.5/site-packages/matplotlib/font_manager.py",
line 512, in createFontDict
font = afm.AFM(fh)
File "/usr/lib/python2.5/site-packages/matplotlib/afm.py", line 294,
in __init__
parse_afm(fh)
File "/usr/lib/python2.5/site-packages/matplotlib/afm.py", line 282,
in parse_afm
dcmetrics_ascii, dcmetrics_name = _parse_char_metrics(fh)
File "/usr/lib/python2.5/site-packages/matplotlib/afm.py", line 167,
in _parse_char_metrics
bbox = _to_list_of_ints(vals[3][2:])
File "/usr/lib/python2.5/site-packages/matplotlib/afm.py", line 47,
in _to_list_of_ints
return [_to_int(val) for val in s.split()]
ValueError: invalid literal for int() with base 10: '691.858'

So I returned back to the old version 0.90.1 which is is Ubuntu
software sources.

Regards,
Petr Muzikar

Petr Muzikar

unread,
Feb 4, 2008, 1:53:03 PM2/4/08
to sage-newbie
Unfortunately the new SAGE 2.10.1 has not fixed my problem. It doesn't
matter :)

Petr Muzikar
Reply all
Reply to author
Forward
0 new messages