On Jun 7, 10:26 am, dbjohn <[email protected]> wrote:
> Yes that code works in a single cell for me. When I put it in an
> interact and plot I get an error. Below is a simplified part of the
> program I am working on. I am using the online notebook. I find when I
> comment out the lines with myTangent the plot will display correctly,
> so there is something wrong with the line I am trying to create.
>
> sage: @interact
> ... def myGraph(a = slider(-5, 5,step_size=1, default=0, label='x
> value')):
> ...           plotA = plot((x^2), x)
> ...           pointA = point((1,1))
> ...           myB = point((3,3))
> ...           myTangent = line([pointA, myB])
> ...           plotA += pointA
> ...           plotA += myB
> ...           plotA += myTangent
> ...           plotA.show(aspect_ratio=1,xmin=-25, xmax=25, ymin=-25,
> ymax=25,figsize=[10, 10])

Compare these two.

> > sage: pointA= (1,1)
> > sage: pointB = (2,2)
> > sage: myline = line([pointA, pointB])
> > sage: myline

Notice that William's pointA is just (1,1), whereas yours is
point((1,1)).    The reason for the unusual error message is that

sage: line??

shows that if we get any error from trying to make a 2D line, it
assumes you want a 3D line.

Try

@interact
def myGraph(a = slider(-5, 5,step_size=1, default=0, label='x
value')):
    plotA = plot((x^2), x)
    pointA = (1,1)
    myB = (3,3)
    myTangent = line([pointA,myB])
    plotA += point(pointA)
    plotA += point(myB)
    plotA += myTangent
    plotA.show(aspect_ratio=1,xmin=-25, xmax=25, ymin=-25,
ymax=25,figsize=[10, 10])

though of course you are not actually using 'a' anywhere in the
interact, but I wasn't sure exactly what your intent was so I left it
alone.  Good luck!

To sage-devel types: would it be worth throwing a check in line for a
Graphics object consisting of one element which is one point, so that
the original thing would work, or is that behavior we don't want to
encourage?

- kcrisman

-- 
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to