ASKSAGE: Sage Q&A Forum - Latest question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 15 Jan 2021 06:10:24 -0600Drawing a line not segmenthttps://ask.sagemath.org/question/55281/drawing-a-line-not-segment/I want to draw a line passing through a point P and Q on an elliptic curve.
E = EllipticCurve([0,0,0,4,20])
print(E)
E.plot(xmin=-20, xmax=20, ymin=-20, ymax=20)
plotE = E.plot()
P=E(1,5)
R = - (P + P)
plotE += line([P.xy(),R.xy()],color='red')
Using this only draw a line segment from P to Q. How can I draw a line? I've looked on the doc but did not see an option for this. Any solution?klxFri, 15 Jan 2021 06:10:24 -0600https://ask.sagemath.org/question/55281/fill between curve and linehttps://ask.sagemath.org/question/45848/fill-between-curve-and-line/Have the function 4-x^6, and the line y=x, how to fill only the area enclosed by the curve and the linegoldsilverbronzeWed, 20 Mar 2019 17:29:32 -0500https://ask.sagemath.org/question/45848/Need help with plottinghttps://ask.sagemath.org/question/44092/need-help-with-plotting/ Trying to plot a line that has one point at (0,0) and the second point at (x(t),y(t)). I am trying to get it to range from t = 0 to 2*pi however, I am not sure how to do it with the line command. I am getting the following error but that is because t has no value defined (TypeError: unable to simplify to float approximation). Appreciate any help!
t = var('t')
x(t) = cos(t) + cos(2t)
y(t) = sin(t) + sin(3*t)
line([(0,0),(x(t),y(t))]
nevar123Fri, 26 Oct 2018 19:41:40 -0500https://ask.sagemath.org/question/44092/animated line drawinghttps://ask.sagemath.org/question/39755/animated-line-drawing/Is it possible to draw a line in sagemath as like javascript?
A Demo: http://jsfiddle.net/m1erickson/7faRQ/kkmiThu, 23 Nov 2017 18:29:45 -0600https://ask.sagemath.org/question/39755/Plotting a linehttps://ask.sagemath.org/question/39441/plotting-a-line/I have
x,y = var('x y')
f = (2*x + 3*y == 0)
How do I plot it
plot(f) gives the error:
Traceback (click to the left of this block for traceback)
...
ValueError: Variable 'y' not found
And since it complained about y, why didn't it complain about x?
Also, where would I find the docs for this question?
And yes, I am a beginner at sagepmgWed, 08 Nov 2017 01:27:48 -0600https://ask.sagemath.org/question/39441/ATAN2 AssertionError while plotting complex squareroot functionhttps://ask.sagemath.org/question/34735/atan2-assertionerror-while-plotting-complex-squareroot-function/<br>I want to plot the real part of a a squareroot function with complex argument by using the SAGE plot method.
<br>This plot method combines function evaluation and plotting within one single python statement.
<br>It fails with the error message :ATAN2 Assertion error.
<br>However, doing the job in two separate consecutive steps , i.e., evaluating the needed function values first and plotting them afterwards with SAGE's line method is successful without error.
<br>The following example code demonstrates this behaviour.
<br>Meaning of variables:
<br>f_exampl: test function calling the real part of a square-root function;
<br>exx=1 uses the method "plot" ;
<br>exx=2 uses the method "line" to plot a pre-calculated list of values.
<br>delta =0: the argument of the square-root is real
<br>delta /= 0 : I*delta is the imaginary part of the squareroot argument.
<br>The result:
<br>testcase exx=2 is successful for delta=0 and delta != 0.
<br>testcase exx=1 is successful for delta=0.
<br>testcase exx=1 aborts with ATAN2 Assertion error if the squareroot must evaluate complex numbers.
<br>Apparently there is a conflict between the evaluation of complex sqareroots during SAGE's plot method.
<br>Evaluating the complex sqareroots without plotting them can be done without problems.
<br>However, In my case it is more convenient to use SAGE's plot instead of SAGE's line method.
<br>Is it possible to avoid the assertion error in the preferred plot method?
<br>I used SAGE Version 7.1 within a Linux opensuse 42.1 OS.
x,delta,exx=var('x', 'delta', 'exx')
delta=0.0
exx=1
def f_exampl(xx):
return sqrt(xx-I*delta)
xmin=1.0
plotpts=2
plotpts_1=plotpts+1
xmax=3.0
ym=2.0
if exx==2:
# exampl_2: no assertion error, if delta != 0:
list_exampl=[[xmin+(xmax-xmin)*i/plotpts,real_part(f_exampl(xmin+(xmax-xmin)*i/plotpts))]for i in range(plotpts_1)]
exampl_2=line(list_exampl,thickness= 2,color='red',marker='+')
show(exampl_2)
else:
# exampl_1: assertion error, if delta != 0:
exampl_1=plot (real_part(f_exampl(x)),(x,xmin,xmax),ymin=1.0,ymax=+ym,plot_points=plotpts,color='blue',marker='+')
show(exampl_1)bekalphMon, 05 Sep 2016 14:59:22 -0500https://ask.sagemath.org/question/34735/sage.plot.plot3d.shapes2.Line() does not work in the cloudhttps://ask.sagemath.org/question/29546/sageplotplot3dshapes2line-does-not-work-in-the-cloud/The following code (straight from http://doc.sagemath.org/html/en/reference/plot3d/sage/plot/plot3d/shapes2.html) does not work in the SageMath Cloud, at least not for me:
from sage.plot.plot3d.shapes2 import Line
Line([(i*math.sin(i), i*math.cos(i), i/3) for i in range(30)], arrow_head=True)
The result is a long error message ending with "TypeError: 0 is not JSON serializable". Am I doing something wrong?Jeremy MartinWed, 23 Sep 2015 13:49:15 -0500https://ask.sagemath.org/question/29546/how to plot a fit linehttps://ask.sagemath.org/question/26738/how-to-plot-a-fit-line/ how do I add a fit line to my graph?
Here is my coding:
initial_val = [100,100,100]
memo = {}
def lizardsquad(n):
if n not in memo:
memo[n] = initial_val if n == 0 else [1*lizardsquad(n-1)[0]-1*lizardsquad(n-1)[1]+2*lizardsquad(n-1)[2], 2*lizardsquad(n-1)[0]+1*lizardsquad(n-1)[1]-1*lizardsquad(n-1)[2],-1*lizardsquad(n-1)[0]+2*lizardsquad(n-1)[1]+1*lizardsquad(n-1)[2]]
return memo[n]
show(list_plot([lizardsquad(i)[0] for i in range(25)], plotjoined=True, color='blue') + (list_plot([lizardsquad(i)[1] for i in range(25)], plotjoined=True, color='orange')) + list_plot([lizardsquad(i)[2] for i in range(25)], plotjoined=True, color='yellow'))
blanchardr2Wed, 06 May 2015 09:51:25 -0500https://ask.sagemath.org/question/26738/Solid lines in plot and grid lineshttps://ask.sagemath.org/question/9244/solid-lines-in-plot-and-grid-lines/I have a plot which sweeps over a range shown below and the plots it on a log scale on the horizontal axis (I am using 5.2 so the log scale feature is present).
1. However, rather than points, I would like to see a solid line and,
2. Some grid lines on both the horizontal and vertical axis at the tick points.
3. Is there also a way to control the range on the vertical axis?
Here is the entire formulation. The range on the y-axis I would like to see labeled is from -5 to -25. I asked a question before using the formulation below but the scale did not was off due to the wrong operator being used so I did not ask that particular question at the time:
z1=2 * pi * 650 * 10^6
p1=2 * pi * 1.9 * 10^9
p2=2 * pi * 5 * 10^9
adc=.667
deltaF=.2 * 10^9
N=(adc * p1 * p2)/z1
M(freq)=(-2 * i * pi * freq + z1)/((-2 * i * pi * freq+p1) * (-2 * i * pi * freq+p2))
g(frq)=20 * abs(log(N * M(frq),10))
pts=[(frq,g(frq).n()) for frq in srange(10^8,10^11,deltaF)]
list_plot(pts, scale='semilogx')gjmThu, 16 Aug 2012 04:42:11 -0500https://ask.sagemath.org/question/9244/Given a direction vector and a point, how to draw a 3d line?https://ask.sagemath.org/question/9003/given-a-direction-vector-and-a-point-how-to-draw-a-3d-line/I have a point
(-e^pi, 0, e^pi)
and a direction vector
tvec = vector((e^t * cos(t) - e^t * sin(t), e^t * sin(t) + e^t * cos(t), e^t))
How would I draw a 3d line based upon these 2 arguments?
I looked over at the documentation but I couldnt find it.dnizeticSat, 26 May 2012 04:51:13 -0500https://ask.sagemath.org/question/9003/Basic vector functions in Sagehttps://ask.sagemath.org/question/8924/basic-vector-functions-in-sage/Isn't there any inbuilt 3D vector functions in Sage?
For instance like a function to get the dot product, cross product or angle between two vectors? Or functions to get the distance from a point to a line? Find the intersections between two lines? Having such functions would be a great help and would greatly increase the speed of my workflow in school.paldepindWed, 25 Apr 2012 00:43:34 -0500https://ask.sagemath.org/question/8924/plotting in a script filehttps://ask.sagemath.org/question/8787/plotting-in-a-script-file/I have install sage in my computer and i have started testing sage examples. I dont understand sth. for example
sage: v = [(1,10),(2,20)]
sage: line(v)
it runs in shell and I can look plot screen.
I try below codes
sage: load "test.sage"
or
But instead of Interactive Shell, when I try to run the file "test.sage",
on terminal :
$ sage test.sage
it isnt right.
bhdrymnMon, 12 Mar 2012 12:52:44 -0500https://ask.sagemath.org/question/8787/line3d fonsize option?https://ask.sagemath.org/question/8607/line3d-fonsize-option/Hi!
I need to hide exact values in 3d plot. In case of 2d I can use fontsize option like:
line([(0,0),(1,1)]).show(fontsize=0)
But show + line3d ignores fontsize option.EugeneWed, 04 Jan 2012 09:15:09 -0600https://ask.sagemath.org/question/8607/fitting a curve to a straight linehttps://ask.sagemath.org/question/7566/fitting-a-curve-to-a-straight-line/How can I use sage to fit some points like
x = [1, 3, 4...]
y = [1.2, 4.5, 3.6, ...]
to a straight line using method of least squares And make a plot of the points and the line?ebsFri, 23 Sep 2011 21:31:50 -0500https://ask.sagemath.org/question/7566/Elegant solution to 'thin out' array and plot linehttps://ask.sagemath.org/question/8231/elegant-solution-to-thin-out-array-and-plot-line/Sometimes I don't know how many points will be in the target array, yet I need to plot a line with markers. If too many points presented, markers on the plot will overlap and an single bold line will be plotted:
line([(x, np.sin(x)) for x in srange(0,np.pi,np.pi/128)], marker='d')
The solution acceptable for me is to 'thin out' input array in order to exclude points, which are too close to each other. My first implementation of such functional is:
def thin_out_array(points, size):
if len(points) <= size: return points
g = int(len(points)/size)
return [p for i,p in enumerate(points) if i % g == 0]
def line(points, thin_out = None, **kwds):
if thin_out: points = thin_out_array(points, thin_out)
return sage.plot.line.line(points, **kwds)
So this code gives line with separated markers:
line([(x, np.sin(x)) for x in srange(0,np.pi,np.pi/128)], marker='d', thin_out = 32)
Perhaps, more clear and common way to do such thing is already designed?
EugeneSat, 16 Jul 2011 08:48:10 -0500https://ask.sagemath.org/question/8231/How to control layouts of individual plots within a graphics_array?https://ask.sagemath.org/question/8156/how-to-control-layouts-of-individual-plots-within-a-graphics_array/I am trying to plot two graphics side-by side from with an '@interact' function within the Sage notebook.
I define my graphics array and render it with the appropriate size as follows:
myGraphicsArray = graphics_array([myPlot1, myPlot2])
myGraphicsArray.show(figsize=[14,5])
This is fine, but how can I control features of the individual plots separately? (e.g. axis range, aspect ratio, maybe even relative sizes of the two plots etc.)
For now I have found a kludge workaround, which is to .show() the individual plots first of all (making them very small) within which I set the relevant layout parameters as follows:
myPlot1.show(ymin=-40,ymax=10,figsize=0.1) # note small figsize
myPlot2.show(xmin=-axisMax, xmax=axisMax, ymin=-axisMax, ymax=axisMax, aspect_ratio=1, figsize=0.1) # note small figsize
This is not ideal, as it plots them (albeit small) when I didn't really want to. But at least it allows me to control their respective layouts when they later appear within the graphics_array.
But is there a better way to do this?
deebs67Thu, 09 Jun 2011 03:42:41 -0500https://ask.sagemath.org/question/8156/