ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 20 Mar 2019 23:29:32 +0100fill 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 23:29:32 +0100https://ask.sagemath.org/question/45848/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 08:27:48 +0100https://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 21:59:22 +0200https://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 20:49:15 +0200https://ask.sagemath.org/question/29546/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 11:42:11 +0200https://ask.sagemath.org/question/9244/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 16:15:09 +0100https://ask.sagemath.org/question/8607/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 15:48:10 +0200https://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 10:42:41 +0200https://ask.sagemath.org/question/8156/