Submitted by Sean Wingert on Sat, 07/18/2015 - 15:49
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