Sage / SageMath: TI-84 / TI-89 Split Screen

Lately, I've been learning the basics of Sage (SageMath). Today, I wanted the equivalent of the TI-84 or TI-89 "split screen" feature with a graph and table of values side-by-side. Here's my attempt: SAGE CODE
x = var('x')
f(x) = x^3
coords = [(i, f(i)) for i in [-3..3]]
fn = 'plot' + str(int(random()*10000)) + '.png' # required due to Sage object caching

p = points(coords,pointsize=40,color='red')
g = plot(f(x),(x, -3,3))
(p+g).save(DATA + fn)

html('<div style="float:left;">')
html("<img src="+fn+"></img>")
html('</div><div style="float:right; padding-left:50px;">')
html.table([["$x$", "$f(x)$"]] + coords, header = True)
html('</div>')

time.sleep(1)
os.remove(DATA + fn)

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.