Re: [sage-support] Problems getting Sage 6.2 & Python (matplotlib) to plot

25 views
Skip to first unread message

Jim Clark

unread,
Jul 2, 2014, 12:14:25 PM7/2/14
to sage-s...@googlegroups.com
From earlier thread, either of two work-arounds worked for me in Sage 6.2:

Work-around #1:
sage: import matplotlib
sage: matplotlib.use(‘agg’)
sage: import matplotlib.pyplot as plt

Work-around #2:
rename ~/.matplotlib/matplotlibrc to .matplotlib/matplotlibrc.bak

Jim Clark
-----Original Message-----
From: LouP
Sent: Jul 2, 2014 8:38 AM
To: sage-s...@googlegroups.com
Subject: [sage-support] Problems getting Sage 6.2 & Python (matplotlib) to plot

0 0 1 301 1716 NRL 14 4 2013 14.0 Normal 0 false false false EN-US JA X-NONE

I am having problems with matplotlib, Sage plotting and, apparently, backends.  I have installed Sage 6.2 on my Mac Book Pro (system 10.6) (I just upgraded from Sage 4.2). I have removed all copies of matplotlibrc from my computer except for the file buried in Sage-6.2/.../mpl_data/. All choices of backend resulted in the errors:  _backend not found, where _backend is the name of the library that should load for the backend (e.g. _tkagg for TKAgg).  My partial solution is to use the _tkagg from my prior Sage version which I produced by a compile many years ago before I had Sage.

I have tried several scenarios to run my code:  iPython (in Terminal), Sage (in Terminal), and as a script.  Scripts and iPython are run through the Sage 6.2 package.  I mostly run from script which has the most problems.  The most successful situation is with TKAgg. However, calling plot(...) and show() from pylab and D.show() from Sage (where D is a graph) have different successes.  Here is a table of what does and does not work (view with monospace font).

Backend   Plot call    iPython  Sage   Script

TKAgg     D.show()     Yes      Yes    No (but Preview does launch)

          pylab.plot() Yes      Yes    Yes 

No

Backend   D.show()     Yes      Yes    No (but Preview does launch)

          pylab.plot() No       No     No

No Backend means I commented out the backend statement in matplotlibrc.

TKAgg is the most successful, but not fully.  And I had to add the _tkagg library to the Sage package.

Sorry for the verbose post, but I thought I'd try several things, first. I did see a previous post about some bug in Sage 6.2 using the wrong .matplotlib folder, but I don't know what that tells me.

I can limp along with what I have above, but any help very appreciated.

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

Code generating problems:

(1) D.show() version:

adjls=[[0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0]]

M= Matrix(adjls)

D= Graph(M)

D.show() 

(2) pylab.plot version:

import numpy as NP

import pylab as PL

x= NP.array([1,2,3,4])

y= x**2

PL.plot(x,y)

PL.show()    

--
You received this message because you are subscribed to the Google Groups "sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sage-support...@googlegroups.com.
To post to this group, send email to sage-s...@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.

LouP

unread,
Jul 2, 2014, 1:09:37 PM7/2/14
to sage-s...@googlegroups.com, jimfort...@earthlink.net
Hi, Jim,
Thanks for the reply.  I tried your suggestions (below), but I am having trouble running from a script, not the Sage or iPython interface for which TKAgg works fine.  As for the script trials I did, #1 doesn't work for either pylab plot or D.show() (a Sage Graph plot).  #2 is not relevant as I have removed matplotlibrc from .matplotlib and other "dot" files in my home directory.  Actually, setting the use to 'agg' is the same as not specifying a backend (my No Backend option in my post).  Thanks.  If I get some answers, i'll post them.

-- Lou
Reply all
Reply to author
Forward
0 new messages