On Jun 10, 11:28 am, Emerson <[EMAIL PROTECTED]> wrote:
> Hello everyone.
>
> I'm just wondering if there's a way of showing a SAGE plot in a window
> when running a code on the script (i.e., a python script ran with the
> sage environment from the command line). To make it more clear, I have
> the code bellow...
>
> #!/usr/bin/env sage
>
> import sys
> from sage.all import *
>
> g = 2
> t = .4
> var('n m')
> d2u = diff(1/(1 + (n * exp(-m/t))), m, 2)
> solns = solve([d2u == 0, m == g], m, n, solution_dict=True)
> ns = [[soln[n].n()] for soln in solns]
> n = ns.pop().pop()
> u = 1/(1 + (n * exp(-m/t)))
> p = plot([u], (-10, 10))
>
> ...and I want to display the plot "p" in a window/frame when i run my
> script from the command line (i.e., ./myScript.py). Any way to do
> that?

Well, I can tell you what sort of worked for me; but it's environment
specific.

The easy part: add a new line "p.show()" at the end of your script;
this should produce a plot and display it with your default image
viewer.

Unfortunately, in my environment, this displays the plot very briefly,
and then the plot disappears.  This is because the .show() command
creates a temporary file and sends it to my image viewer (Eye of
Gnome); then when Sage exits, it removes all its temporary files.  Eye
of Gnome notices that the file it was viewing went away, and stops
showing the file.

There's surely an easy fix or workaround for this, but I don't have
time to look into it; one easy but very unsatisfying workaround is to
add another line "sleep(100)" to your script, to let you view the
image for 100 seconds before it disappears.

Carl

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to