> 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.

Okay it works when I define a point with just the coordinates like you
said. So is the lesson that when you pass the two points to a line:
ensure that they are defined by just the coordinates otherwise it will
think you are trying to make a 3d line which it can't do.

But suppose I want the point to be of a certain color or size, I need
to use point() like: point((1,1),rgbcolor=hue(0.75),size=100)

And then pass to line() which won't work. I tried calling its
attributes separately like

pointA = (1,1)
pointA.size = 100.

Didn't work either.

I notice you also added point like point(pointA), I didn't realise you
could do that.

> 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!

Yes you can ignore the interact 'a' variable I defined in the above
program, I know it doesn't do anything now.

On Jun 7, 3:51 pm, kcrisman <kcris...@gmail.com> wrote:
> On Jun 7, 10:26 am, dbjohn <johndbren...@gmail.com> 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 sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to