Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Matplotlib Show() on Sage command line on Mac OS X

Received: by 10.180.8.196 with SMTP id t4mr1423835wia.3.1353306088010;
        Sun, 18 Nov 2012 22:21:28 -0800 (PST)
X-BeenThere: sage-devel@googlegroups.com
Received: by 10.180.104.35 with SMTP id gb3ls1174921wib.30.canary; Sun, 18 Nov
 2012 22:21:23 -0800 (PST)
Received: by 10.204.10.80 with SMTP id o16mr595528bko.4.1353306083158;
        Sun, 18 Nov 2012 22:21:23 -0800 (PST)
Received: by 10.204.10.80 with SMTP id o16mr595527bko.4.1353306083141;
        Sun, 18 Nov 2012 22:21:23 -0800 (PST)
Return-Path: <gcmss-sage-deve...@m.gmane.org>
Received: from plane.gmane.org (plane.gmane.org. [80.91.229.3])
        by gmr-mx.google.com with ESMTPS id 7si461361bkr.3.2012.11.18.22.21.22
        (version=TLSv1/SSLv3 cipher=OTHER);
        Sun, 18 Nov 2012 22:21:23 -0800 (PST)
Received-SPF: pass (google.com: domain of gcmss-sage-deve...@m.gmane.org designates 80.91.229.3 as permitted sender) client-ip=80.91.229.3;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of gcmss-sage-deve...@m.gmane.org designates 80.91.229.3 as permitted sender) smtp.mail=gcmss-sage-deve...@m.gmane.org
Received: from list by plane.gmane.org with local (Exim 4.69)
	(envelope-from <gcmss-sage-deve...@m.gmane.org>)
	id 1TaKjb-0001IX-GF
	for sage-devel@googlegroups.com; Mon, 19 Nov 2012 07:21:31 +0100
Received: from 103.11.50.1 ([103.11.50.1])
        by main.gmane.org with esmtp (Gmexim 0.1 (Debian))
        id 1AlnuQ-0007hv-00
        for <sage-devel@googlegroups.com>; Mon, 19 Nov 2012 07:21:31 +0100
Received: from ppurka by 103.11.50.1 with local (Gmexim 0.1 (Debian))
        id 1AlnuQ-0007hv-00
        for <sage-devel@googlegroups.com>; Mon, 19 Nov 2012 07:21:31 +0100
X-Injected-Via-Gmane: http://gmane.org/
To: sage-devel@googlegroups.com
From: P Purkayastha <ppu...@gmail.com>
Subject: Re: Matplotlib Show() on Sage command line on Mac OS X
Date: Mon, 19 Nov 2012 14:21:08 +0800
Lines: 30
Message-ID: <k8cj4j$79m$1@ger.gmane.org>
References: <51123a5d-4e1a-4221-ad62-bb6c28053aab@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Complaints-To: use...@ger.gmane.org
X-Gmane-NNTP-Posting-Host: 103.11.50.1
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121026 Thunderbird/16.0.2
In-Reply-To: <51123a5d-4e1a-4221-ad62-bb6c28053aab@googlegroups.com>

On 11/19/2012 10:41 AM, Eric Verner wrote:
> When I try to plot data using matplotlib from the sage command line using show(), nothing happens. I have done some research and tried several different backends to matplotlib in the matplotlibrc file, including Cairo, GTK, WX, Agg, and MacOSX, and nothing works. I have tried to install pygtk and pycairo to Sage with no luck. Can someone give me a concise, straightforward way to get show() to work on my computer (Mac OS X 10.6.8). I would be very grateful. Thanks.
>

You can't, AFAIK. Matplotlib figures are not Sage objects. When you use 
show(some_figure), it usually calls some_figure.show() which is a Sage 
method.

One option for you would be to declare a simple class which takes a 
matplotlib object and which has a show() method. In the show() method 
you can save your figure to some temporary file and then call some image 
viewer to view the file. This applies only for the command line. Look at 
the very end of the output when you run the following commands, on how 
to call your image viewer:
sage: p = Graphics()
sage: p.show??

Also, ticket #5128 would be of interest to you:
http://trac.sagemath.org/5128


On a notebook, you simply need to save the figure and it will 
automatically be shown on the cell output. So, you would do:

<do all your matplotlib commands>
<let's suppose, for simplicity you were using pyplot>
plt.savefig('./figure.png')

and it will show up in your cell output.