Ask Your Question
1

list_plot() not working in a terminal session

asked 2015-02-02 15:09:27 +0100

fbarbuto gravatar image

Hello,

list_plot() does not produce any plot when I run a script in a terminal (pure text) session. But it does when I run the same script in SAGE's graphical ("notebook()") environment. However, in both ways the execution ends normally (no error messages).

Curiously, if I type list_plot(...array name goes here...) in the terminal after the execution of the aforementioned script, a plot is produced.

Any explanation for that? The script is quite simple and short as shown below.

Thanks for any help.

import time
from sage.all import *
import math

n = [19, 31, 61, 127]
l=len(n)
c = []

for i in range(l-1):
    for k in range(i+1,l):
        ai = 2**n[i]-1
        ak = 2**n[k]-1
        temp = ai*ak
        print ai, ak, ai*ak
        start_cpu = time.clock()
        divs = prime_divisors(temp)     
        cpu_t = time.clock() - start_cpu
        c.append((math.log10(1.0*ai*ak),cpu_t))
        print divs
        print 'CPU time = %.3e \n' % (cpu_t)

list_plot(c)
edit retag flag offensive close merge delete

Comments

My setup: OS X 10.10.2, Sage 6.5.beta2. With your exact code, I get the plot displayed (an external viewer, Preview, is started and the plot is displayed there). What OS and what version of Sage are you using?

slelievre gravatar imageslelievre ( 2015-02-02 16:00:10 +0100 )edit

Hi, Sorry for taking too long to reply. I had problems signing in and had to create another account. I'm using SAGE 6.4 on a Ubuntu 14.04-64bit machine. Thanks.

fausto_barbuto gravatar imagefausto_barbuto ( 2015-02-02 19:21:21 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2015-02-03 02:42:15 +0100

fbarbuto gravatar image

I found the solution for this problem. All I had to do was to replace the following line:

list_plot(...)

by the following two lines:

p = list_plot(...)

p.show()

And then a plot was plotted.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-02-02 15:09:27 +0100

Seen: 932 times

Last updated: Feb 03 '15