ASKSAGE: Sage Q&A Forum - Latest question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 08 Oct 2019 17:02:55 -0500list_plot generatorhttp://ask.sagemath.org/question/48239/list_plot-generator/I have created a python generator that yeilds a list of single values (e.g. like [1,971,15,341,..]) up to some defined length of n,and wanted to plot them in sagemath.
When I pass the generator to list_plot, I get an error as list_plot only accepts lists, tuples and dictionaries.
Is there any way to get the list_plot behaviour from a generator without converting to a list first (To memory-hungry for my purpose)?
If not, I'm planning to request an enhancement to list_plot, if at all possible.JoalHeagneyTue, 08 Oct 2019 17:02:55 -0500http://ask.sagemath.org/question/48239/Plotting derivative of bump functionhttp://ask.sagemath.org/question/47169/plotting-derivative-of-bump-function/ I wish to plot the derivative of the piecewise function equal to $\exp((1 - x^2)^{-1})$ on (-1, 1) and 0 everywhere else (just as an example). I attempted this by defining to define in sage
`f(x) = piecewise([(-oo, -1), 0], [(-1, 1), exp(-1/(1 - x^2)), [(1, oo), 0]]`
and then let `g = diff(f(x), x))`. When i try to evaluate g at various values (for example 0.3), I get 0.333237077156224*(0, 0, 0) + 0.333237077156224, and the number that appears is not only incorrect (in that it is not the derivative it ought to equal), but the expression that appears can't be turned into a single number. My ultimate objective is to obtain plots of various linear combinations of such expressions, so what would be the best way to go about doing this? In addition, what exactly is going on here?alpha0Mon, 15 Jul 2019 10:58:12 -0500http://ask.sagemath.org/question/47169/Octave-like plot function, or, how to plot sequence of points?http://ask.sagemath.org/question/47029/octave-like-plot-function-or-how-to-plot-sequence-of-points/Let's say I have the following set of points: (1, 2), (5, 8), (7, 13), (8, 10), (8.7, 9), (10, 6.3), (13, 2), (15, -1).
I would like to plot a 2D graph passing through them.
In octave, I can do the following:
octave:47> x = [1, 5, 7, 8, 8.7, 10, 13, 15]
octave:48> y = [2, 8, 13, 10, 9, 6.3, 2, -1]
octave:49> plot(x, y)
And I get this [graph](https://drive.google.com/open?id=1iE4hhpcYBGwjAvF45F_hruxKwpl3ccvV).
How can I do something similar in sage?
Hilder Vítor Lima PereiraTue, 02 Jul 2019 02:00:09 -0500http://ask.sagemath.org/question/47029/Plotting Graphs with different size verticeshttp://ask.sagemath.org/question/46953/plotting-graphs-with-different-size-vertices/ Hi, I'm trying to plot a graph where all vertices have a different size, depending on a value assigned to them, so a vertex with a high value would have a larger circumference.
I don't really know where to start. Can you help me?ga38xabThu, 20 Jun 2019 05:58:49 -0500http://ask.sagemath.org/question/46953/plotting multiple functions from a for loophttp://ask.sagemath.org/question/46357/plotting-multiple-functions-from-a-for-loop/ This solution:
https://ask.sagemath.org/question/9024/plotting-multiple-functions-from-a-for-loop/#
is not working any more
The error is:
Error in lines 3-3
Traceback (most recent call last):
File "/cocalc/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 1188, in execute
flags=compile_flags) in namespace, locals
File "", line 1, in <module>
File "/ext/sage/sage-8.7_1804/local/lib/python2.7/site-packages/sage/misc/decorators.py", line 492, in wrapper
return func(*args, **options)
File "/ext/sage/sage-8.7_1804/local/lib/python2.7/site-packages/sage/plot/plot.py", line 1956, in plot
G = _plot(funcs, (xmin, xmax), **kwds)
File "/ext/sage/sage-8.7_1804/local/lib/python2.7/site-packages/sage/plot/plot.py", line 2224, in _plot
legend_label=legend_label_entry, legend_color=legend_color_entry, **options_temp)
File "/ext/sage/sage-8.7_1804/local/lib/python2.7/site-packages/sage/misc/decorators.py", line 492, in wrapper
return func(*args, **options)
File "/ext/sage/sage-8.7_1804/local/lib/python2.7/site-packages/sage/plot/plot.py", line 1941, in plot
G = funcs.plot(*args, **original_opts)
TypeError: plot() takes exactly 1 argument (17 given)thethaThu, 25 Apr 2019 04:06:52 -0500http://ask.sagemath.org/question/46357/fill between curve and linehttp://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 -0500http://ask.sagemath.org/question/45848/False implicit plothttp://ask.sagemath.org/question/45627/false-implicit-plot/Hello
I write in SAGE
implicit_plot(y==1/2, (-1,1),(-1,1))
and it returns the graph of the line x=1/2. Why? creyesm1992Sun, 03 Mar 2019 11:38:12 -0600http://ask.sagemath.org/question/45627/draw all faces of alcoves (affine root system)http://ask.sagemath.org/question/45354/draw-all-faces-of-alcoves-affine-root-system/I am trying to plot alcoves for in a rank 3 affine root system with some of those alcoves highlighted by having all faces drawn and the others only shown as a wire frame.
The manual on visualising root systems at sagemath.org is quite useful, but I have some effects show that I don't understand.
For some reason while the fundamental alcove will have all faces shown many of the others have not, that is, some faces are missing. Below you find one example code that I have done. For the chosen seq one face is missing, the red one. For other choices of seq one might even see only one face drawn. How do I force to have all faces shown?
L = RootSystem(["A",3,1]).ambient_space()
P = RootSystem(["A",3,1]).weight_space(extended=True)
Lambda = P.fundamental_weights()
W = L.weyl_group()
W0=W.classical()
plot_options = L.plot_parse_options()
seq=[2,3,1,2]
t = 1*Lambda[1]-1*Lambda[2]+1*Lambda[3]
Alcoves=[W.from_reduced_word(w.reduced_word()) for w in W0]
p = L.plot_fundamental_chamber("classical")
p += L.plot_fundamental_weights()
p += L.plot_alcoves(alcoves=Alcoves, wireframe=True)
p += L.plot_alcoves(alcoves=[W.from_reduced_word(seq)])
p += L.plot_alcoves(alcoves=[W.from_reduced_word([])])
p += plot_options.family_of_vectors({t: L(t)})
p.show(frame=False)oloidThu, 07 Feb 2019 09:08:34 -0600http://ask.sagemath.org/question/45354/implicit_plot plot of a listhttp://ask.sagemath.org/question/45196/implicit_plot-plot-of-a-list/ Hello,
On Sage 8.5, Release Date: 2018-12-22, I am doing
`var('x,y')`
`F1 =plot([k/x for k in [-5..5]], (-5, 5), ymin=-5, ymax = 5, detect_poles=True, color="red")`
`F2= implicit_plot([y^2 - x^2 -c for c in [-5..5]], (x,-5,5), (y,-5,5))`
to obtain two families of orthogonal curves. While the first family is ok, there seems to be a problem with the second one.
I can circunvent my problem by doing a lis of plots (instead of the plot of a list), as follows :
`[implicit_plot(y^2 - x^2 -c ==0, (x,-5,5), (y,-5,5), color="blue" ) for c in [-5..5]]`
I was expecting that `plot(...)` and `implicit_plot(...)` would beheave in the same manner in this situation. Why this is not the case? Am I missing something in the syntax?
Regards,
JC
JCSat, 26 Jan 2019 21:47:23 -0600http://ask.sagemath.org/question/45196/Combine plots with built-in Maxima, trajectory in Sage available?http://ask.sagemath.org/question/44995/combine-plots-with-built-in-maxima-trajectory-in-sage-available/I want to combine the following plots as one output figure:
maxima('plotdf(4*y/x+x*sqrt(y),[trajectory_at,1,1],[x,0,4],[y,0,10])')
maxima('plot2d(1/4*x^4*(log(x)+2)^2,[x,0,4],[y,0,10])')
How can I achieve that? However, if there is any way to output a trajectory by Sage directly, I would be very happy. With pure Sage, I've just achieved this so far:
plot_slope_field(4*y/x+x*sqrt(y),(x,0,4),(y,0,10),headaxislength=3,headlength=3)ThrashThu, 10 Jan 2019 13:45:43 -0600http://ask.sagemath.org/question/44995/Can't display figureshttp://ask.sagemath.org/question/44953/cant-display-figures/hello,
i installed Sage on a new computer this morning,
but i can't display any figures.
That's the error i get :
> /home/xxx/Documents/SageMath/local/lib/python2.7/site-packages/sage/\
repl/rich_output/display_manager.py:592: RichReprWarning: Exception in
_rich_repr_ while displaying object: libtk8.6.so: cannot open shared
object file: No such file or directory
RichReprWarning,
Graphics object consisting of 1 graphics primitive
Anyone got an idea why?
i'm using the notebook of sagemaths
Thanks.tommeTue, 08 Jan 2019 05:15:39 -0600http://ask.sagemath.org/question/44953/Why doesn't assume(x, 'real') exclude complex values when using plot(x^(1/3)) over a negative domain?http://ask.sagemath.org/question/44798/why-doesnt-assumex-real-exclude-complex-values-when-using-plotx13-over-a-negative-domain/ Running the following commands:
assume(x,'real')
plot(x^(1/3), -5, 5)
produces the following error:
verbose 0 (3630: plot.py, generate_plot_points) WARNING: When plotting, failed to evaluate function at 100 points.
verbose 0 (3630: plot.py, generate_plot_points) Last error message: 'negative number cannot be raised to a fractional power'
Shouldn't the assume command take care of this?
Thanks.
douglas.y.youngThu, 27 Dec 2018 21:04:18 -0600http://ask.sagemath.org/question/44798/another 'how to save a plot' questionhttp://ask.sagemath.org/question/44662/another-how-to-save-a-plot-question/ I use SageMath in CoCalc to generate images for worksheets, handouts, exams, etc. I am able to save simple plots to image files, but more complex plots like the one below vex me. Can someone tell me how to save the plot to an image file?
<pre>
plot1 = plot(-(x-1)^2+3, x, -3, 2.98)
plot2 = plot(-abs(2*(x-5))+2, x, 3,5.95)
plot3 = plot((x-7)^2-1,x,6.05,10)
pt1 = circle((6, 0),.1, edgecolor='black')
pt2 = point((6, 3), rgbcolor='black', pointsize=30)
pt3 = point((1, 2), rgbcolor='black', pointsize=30)
pt4 = circle((3, -1),.1, edgecolor='black')
pt3 = point((3, -2), rgbcolor='black', pointsize=30)
g3=(plot1+plot2+plot3+pt1+pt2+pt3+pt4).show(xmin=-2, xmax=10, ymin=-4, ymax=6,gridlines="minor").save('diagram2-finalexam01.png')
g3.save('diagram2-exam02.png')
</pre>
The last line throws the following error and no image file is saved:
<pre>
Error in lines 9-9
Traceback (most recent call last):
File "/cocalc/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 1188, in execute
flags=compile_flags) in namespace, locals
File "", line 1, in <module>
AttributeError: 'NoneType' object has no attribute 'save
</pre>
I've resorted to just taking a screenshot of the plot and using it, but I'd much rather do this in a pythonistic way. Can someone point me in the right direction?
jasonemillerThu, 13 Dec 2018 11:57:55 -0600http://ask.sagemath.org/question/44662/Only one of two identical entries in the notebook gives graphics output for show()http://ask.sagemath.org/question/43638/only-one-of-two-identical-entries-in-the-notebook-gives-graphics-output-for-show/I use SageMath to teach a bunch of kids. I have to confess a certain amount of frustration with the SageMath notebook. In particular, tonight I composed a notebook entry which shows some data points and curve-fitted plots. I pressed Shift-Enter to evaluate, and there was no graphical output (nor any error message).
And then I copied/pasted the exact same entry into a blank entry in the same SageMath notebook, pressed Shift-Enter, and it showed the graphical output.
Yes, this is the SAME notebook page which, if you scroll up, shows no graphical output (I inserted a print("Ok.") just to confirm that there was SOME output), and if you scroll down, you see the IDENTICAL python-like SageMath script, and then it shows the graphics of the plotted points as desired.
How could this happen? Is there something that happens in between notebook entries? Perhaps only the last entry is evaluated? I will try posting screenshots.
ok, the screen shots are as follows:
<a href="https://pasteboard.co/HDowwUc.png">no plot, just text</a>
<a href="https://pasteboard.co/HDoxbZ1.png">plot after the text</a>
in the first entry, you can see the notebook entry, and then underneath in blue the SageMath output "Ok.", and that's all; the next notebook entry follows immediately. There is no plot.
in the second entry, you can see the notebook entry, and then underneath in blue the SageMath output "Ok.", and under that is the plot of the two data points and the axes.
For what it's worth, the SageMath notebook entry is as follows. The variable "stage" is so that I can easily turn on/off various parts of the entry by modifying it as I get to various parts of the lesson. (But there is no difference between the entry that works and the entry that doesn't.)
"all_go" is the accumulation of all the graphics objects that I want to display, that is, the output of the points() function in this case, and depending on the setting of my "stage" variable, possibly also a plot of f(x).
I am using SageMath 7.5.1 on Kubuntu 14.04. I know it's not the newest version, but I mst be missing something.
Any help would be appreciated
<pre>
---( start )---
stage="p2m1"
# stage can be p2 or p3 = data points
# stage can be d0 or d1 = display
# stage can be m1 or m2 or me = model
var('a,b,c')
if stage.find("p2") >= 0 :
mydata = [[1,2],[3,5]]
else :
mydata = [[1,2],[2,4],[3,5]]
#mydata
mydata_plot = points(mydata,color='purple', size=100)
if stage.find("m1") >= 0 :
mymodel(x) = b*x + c
elif stage.find("m2") >= 0 :
mymodel(x) = a*x^2 + b*x + c
elif stage.find("me") >= 0 :
mymodel(x) = a*exp(b*x) + c
myfit = find_fit(mydata,mymodel,solution_dict=True)
if stage.find("m1") >= 0 :
f(x) = mymodel(b=myfit[b], c=myfit[c])
else :
f(x) = mymodel(a=myfit[a], b=myfit[b], c=myfit[c])
#f(x) = 6 - 2^(3-x)
#f(x) = (-8) * exp( x*(-ln(2))) + 6
mymodel_plot = plot( f, (x,0,4,), color='red')
all_go = mydata_plot
if stage.find("d1") >= 0 :
all_go += mymodel_plot
t_min=0
t_max=5
t_default=1.5
sample_t=t_default
global_go = all_go
all_go
if stage.find("d1") < 0 :
all_go.show()
print("Ok.")
elif stage.find("d1") >= 0 :
@interact
def _(sample_t=slider(t_min, t_max, default=t_default, step_size=0.1)):
global global_go
all_go = global_go
#sample_t=2
output_y = f(sample_t)
point_tuple = ( sample_t, output_y )
plotpoint_go = point2d( point_tuple , size=200, color='green')
all_go += plotpoint_go
all_go.show()
f.show()
print( "f(" + str(sample_t) + ") = " + str(output_y) )
---( end )---
</pre>
quantumTue, 11 Sep 2018 08:14:09 -0500http://ask.sagemath.org/question/43638/Ploting ODE (unable to simplify to float approximation)http://ask.sagemath.org/question/42487/ploting-ode-unable-to-simplify-to-float-approximation/I wanted to to draw the slope field aswell as the solution for my ODE.
When I try to plot the solution i get a warning and an error.
verbose 0 (3749: plot.py, generate_plot_points) WARNING: When plotting, failed to evaluate function at 200 points.
verbose 0 (3749: plot.py, generate_plot_points) Last error message: 'unable to simplify to float approximation'
My Code:
----------
y = function('y')(x)
a,b,c,d=var('a b c d')
_C=var('_C')
a=1
b=0
c=0
d=1
de = diff(y,x) == (a*x+b*y)/(c*x+d*y)
h = desolve(de, y, ivar=x);
h=h.substitute(_C==0)
h
y = var('y')
x = var('x')
Plot1=plot_slope_field(((a*x+b*y)/(c*x+d*y)),(x,-10,10),(y,-10,10))
Plot2=plot(h,(x,0,5))
Plot1+Plot2MarsupilamieSun, 03 Jun 2018 13:53:10 -0500http://ask.sagemath.org/question/42487/Animate Bar Graphhttp://ask.sagemath.org/question/24783/animate-bar-graph/In SAGE, is there a way to use the animate command in conjunction with a bar graph?
I can't seem to get it to work. Let's say for argument's sake I want to have a list of N elements and I want to animate reading in each element and sort them by parity then display the output on a bargraph and then animate this through N iterations.
Thank you!sagebarTue, 04 Nov 2014 12:39:58 -0600http://ask.sagemath.org/question/24783/How do I plot a real function whose computation involves complex intermediate results?http://ask.sagemath.org/question/41875/how-do-i-plot-a-real-function-whose-computation-involves-complex-intermediate-results/ I have an algebraic expressing **ev** for an eigenvalue of a 4x4 matrix and I want to plot it.
The expression has square roots and cube roots, and sometimes there are complex intermediate
results although the final result is real. With float, the imaginary part will be non-zero due to numeric errors, but I can just ignore it. Still, when I try to plot this function, I get error messages.
var("u")
ev = (1/2*u + 1/2*sqrt(2/3*u^2 - 1/9*(u^4 - 18*u)/(1/27*u^6 - u^3 +
1/6*sqrt(-32/3*u^6 + 252*u^3 + 9) + 1/2)^(1/3) - (1/27*u^6 - u^3 +
1/6*sqrt(-32/3*u^6 + 252*u^3 + 9) + 1/2)^(1/3) + 6/sqrt((u^4 +
3*(1/27*u^6 - u^3 + 1/6*sqrt(-32/3*u^6 + 252*u^3 + 9) + 1/2)^(1/3)*u^2 -
18*u + 9*(1/27*u^6 - u^3 + 1/6*sqrt(-32/3*u^6 + 252*u^3 + 9) +
1/2)^(2/3))/(1/27*u^6 - u^3 + 1/6*sqrt(-32/3*u^6 + 252*u^3 + 9) +
1/2)^(1/3))) + 1/6*sqrt((u^4 + 3*(1/27*u^6 - u^3 + 1/6*sqrt(-32/3*u^6 +
252*u^3 + 9) + 1/2)^(1/3)*u^2 - 18*u + 9*(1/27*u^6 - u^3 +
1/6*sqrt(-32/3*u^6 + 252*u^3 + 9) + 1/2)^(2/3))/(1/27*u^6 - u^3 +
1/6*sqrt(-32/3*u^6 + 252*u^3 + 9) + 1/2)^(1/3)))
print ev.subs(u=2.6)
print ev.subs(u=3.0)
print ev.subs(u=3.0).real()
plot(ev.subs(u=x).real(),(x,2.6,3))
Plotting will draw only from 2.6 to 2.62 and then abort with the following error message
verbose 0 (3749: plot.py, generate_plot_points) WARNING: When plotting, failed to evaluate function at 189 points.
verbose 0 (3749: plot.py, generate_plot_points) Last error message: 'math domain error'
I tried this in the sage cell server. (On my outdated office computer installation, sage 7.4, I get a different error "AssertionError".)Günter RoteWed, 04 Apr 2018 04:46:06 -0500http://ask.sagemath.org/question/41875/Label function automaticaly, 2d plothttp://ask.sagemath.org/question/41482/label-function-automaticaly-2d-plot/Function:
def random_between(j,k):
a=int(random()*(k-j+1))+j
return a
t = var('t')
m1=random_between(-5,5)
b1=random_between(-5,5)
y1=m1*t+b1
m2=random_between(-5,5)
b2=random_between(-5,5)
y2=m2*t+b2
m3=random_between(-5,5)
b3=random_between(-5,5)
y3=m3*t+b3
m4=random_between(-5,5)
b4=random_between(-5,5)
y4=m4*t+b4
p1=plot(y1, (t,-5,5), gridlines=True,color='red')
p2=plot(y2, (t,-5,5), gridlines=True,color='green')
p3=plot(y3, (t,-5,5), gridlines=True,color='orange')
p4=plot(y4, (t,-5,5), gridlines=True,color='pink')
p=p1+p2+p3+p4
show(p)
Well, I would like to view full grid, and auto lable functions, is this possible, i have here 3 Books, do i have to look somewhere else?thethaSat, 10 Mar 2018 18:30:44 -0600http://ask.sagemath.org/question/41482/Plotting in Sagehttp://ask.sagemath.org/question/41250/plotting-in-sage/I have some numbers in two separate arrays, and I want to plot them in such a way that the end result looks more or less like this:
![image description](/upfiles/15194978051374454.png)
Currently, I have a code that looks like this:
res_blue = [...] # data for the blue circles (removed for brevity)
res_red = [...] # data for the red crosses (removed for brevity)
list_plot(res_red, color='red')
But, instead the above code generates only plot with red dots. How can I combine the two arrays in the same plot, choose their color and the shape to be put in the plot?ninhoSat, 24 Feb 2018 12:46:39 -0600http://ask.sagemath.org/question/41250/Bar chart bar widthhttp://ask.sagemath.org/question/40923/bar-chart-bar-width/ Is there a way to set a different width for each column in the `sage.plot.bar_chart.BarChart` class?davidcorbinThu, 01 Feb 2018 11:09:07 -0600http://ask.sagemath.org/question/40923/plots of complex numbershttp://ask.sagemath.org/question/40831/plots-of-complex-numbers/Say I want to plot the 6 solutions of [the following complex equation](https://sagecell.sagemath.org/?z=eJwrSyzSUK9S1-TlKs7PKS3JzM8rVlCwVQByylIVNKrizGxtdS10FKqACtLyixQyFTLzFIoS89JTNQx0zDSteLkUgKA4I79cA64_OjNWEwBzHBo2&lang=sage).
What is the best practice?
**EDIT** by @tmonteil: to lower dependency between Sage services in the long term, here is the code provided in the sagecell:
var('z')
solutions = solve (z^6==-8, z)
for i in range(0,6):
show(solutions[i])BostonSun, 28 Jan 2018 16:20:47 -0600http://ask.sagemath.org/question/40831/Drawing a planar multigraph with loopshttp://ask.sagemath.org/question/40548/drawing-a-planar-multigraph-with-loops/ I would like to draw a planar graph with multiple edges and loops in Sage. Unfortunately, the default algorithm draws may intersecting edges and Sage is unable to compute an embedding for graphs with loops multiple edges.
Fortunately I know a planar embedding of this graph, so I tried using the `set_embedding` method, but it doesn't seem to work, either. If I only list a vertice's the neighbours, omitting their multiplicities, Sage complains that the list is shorter than the vertice's degree, while if I include multiple copies of each neighbour according to multiplicity, then Sage complains that elements of the list aren't unique.
Is there a way to achieve what I need?A.P.Wed, 10 Jan 2018 07:00:59 -0600http://ask.sagemath.org/question/40548/Plot/Show Png/jpg in sagemath worksheethttp://ask.sagemath.org/question/40501/plotshow-pngjpg-in-sagemath-worksheet/Hello every one, I am testing sagemath for course creation. What is the fastest way to embeed png pictures and diplay them? Something like this: https://paper.dropbox.com/doc/Ubung-Lagebeziehung-Gerade-Gerade-NiPkMCucw7FeDxj15u6aZ?_tk=share_copylink thethaSat, 06 Jan 2018 09:44:00 -0600http://ask.sagemath.org/question/40501/What to do to save a plot from notebook?http://ask.sagemath.org/question/39624/what-to-do-to-save-a-plot-from-notebook/Is it possible to export a plot, preferable in a vector format from a notebook?boosterFri, 17 Nov 2017 02:24:37 -0600http://ask.sagemath.org/question/39624/plotting bughttp://ask.sagemath.org/question/39460/plotting-bug/I wanted to plot this function:
f(x) = x^2 + 1/x
and I plotted it using this command:
plot(f, (x, -100, 100))
and when I plotted it I got a wrong plot:
[see in sagecell](https://sagecell.sagemath.org/?z=eJxL06jQVLBVqIgzUtBWMNSv4OXi5SrIyS_RSNNR0KjQUdA1NDDQUQASmpoA34YJmA==&lang=sage)KamalThu, 09 Nov 2017 11:08:00 -0600http://ask.sagemath.org/question/39460/Plotting a linehttp://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 -0600http://ask.sagemath.org/question/39441/Sage on Mac unable to use plot3d due to Java/jmol issueshttp://ask.sagemath.org/question/39422/sage-on-mac-unable-to-use-plot3d-due-to-javajmol-issues/Hi,
I am a relative newbie to the Mac and Sage on the Mac. I tried to run the following code from the Sage tutorial on my Mac in the console mode of sage:
> sage: x, y = var('x,y')
>
> sage: plot3d(x^2 + y^2, (x,-2,2), (y,-2,2))
The error message I get is
> --------------------------------------------------------------------------- RuntimeError
> Traceback (most recent call last)
> <ipython-input-2-878191366deb> in
> <module>()
> ----> 1 plot3d(x**Integer(2) + y**Integer(2),
> (x,-Integer(2),Integer(2)),
> (y,-Integer(2),Integer(2)))
>
> /Applications/SageMath/local/lib/python2.7/site-packages/IPython/core/displayhook.pyc in __call__(self, result)
> 244 self.start_displayhook()
> 245 self.write_output_prompt()
> --> 246 format_dict, md_dict =
> self.compute_format_data(result)
> 247 self.update_user_ns(result)
> 248 self.fill_exec_result(result)
>
> /Applications/SageMath/local/lib/python2.7/site-packages/IPython/core/displayhook.pyc in compute_format_data(self, result)
> 148
> 149 """
> --> 150 return self.shell.display_formatter.format(result)
> 151
> 152 # This can be set to True by the write_output_prompt method in a
> subclass
>
> /Applications/SageMath/local/lib/python2.7/site-packages/sage/repl/display/formatter.pyc
> in format(self, obj, include, exclude)
> 158 # First, use Sage rich output if there is any
> 159 PLAIN_TEXT = u'text/plain'
> --> 160 sage_format, sage_metadata =
> self.dm.displayhook(obj)
> 161 assert PLAIN_TEXT in sage_format, 'plain text is always
> present'
> 162 if sage_format.keys() != [PLAIN_TEXT]:
>
> /Applications/SageMath/local/lib/python2.7/site-packages/sage/repl/rich_output/display_manager.pyc
> in displayhook(self, obj)
> 806 self._backend.set_underscore_variable(obj)
> 807 plain_text, rich_output =
> self._rich_output_formatter(obj,
> dict())
> --> 808 return self._backend.displayhook(plain_text,
> rich_output)
> 809
> 810 def display_immediately(self, obj,
> **rich_repr_kwds):
>
> /Applications/SageMath/local/lib/python2.7/site-packages/sage/repl/rich_output/backend_ipython.pyc
> in displayhook(self, plain_text,
> rich_output)
> 264 return ({u'text/plain': msg}, {})
> 265 elif isinstance(rich_output,
> OutputSceneJmol):
> --> 266 msg = self.launch_jmol(rich_output,
> plain_text.text.get_unicode())
> 267 return ({u'text/plain': msg}, {})
> 268 elif isinstance(rich_output,
> OutputSceneWavefront):
>
> /Applications/SageMath/local/lib/python2.7/site-packages/sage/repl/rich_output/backend_ipython.pyc
> in launch_jmol(self, output_jmol,
> plain_text)
> 367 jdata = JmolData()
> 368 if not jdata.is_jvm_available() and not
> DOCTEST_MODE:
> --> 369 raise RuntimeError('jmol cannot run, no
> suitable java version found')
> 370 launch_script = output_jmol.launch_script_filename()
> 371 from sage.env import SAGE_LOCAL
>
> RuntimeError: jmol cannot run, no
> suitable java version found
I believe I have the latest version of Java installed:
> $ java --version
> java 9.0.1
> Java(TM) SE Runtime Environment (build 9.0.1+11)
> Java HotSpot(TM) 64-Bit Server VM (build 9.0.1+11, mixed mode)
Sage version
> $ sage --version
> SageMath version 8.0, Release Date: 2017-07-21
I would appreciate any inputs and advice about how to fix this issue. Thanks in advance!toricwebTue, 07 Nov 2017 10:29:46 -0600http://ask.sagemath.org/question/39422/plot operation errorhttp://ask.sagemath.org/question/39148/plot-operation-error/I'm trying to plot the following.
def myfn2(x):
if x<0:
return 1
else:
return -1
plot(myfn2(x),x,-3,3,figsize=3,color="red")
The graph is only displayed as -1. Why?matxzeroThu, 12 Oct 2017 19:38:19 -0500http://ask.sagemath.org/question/39148/connecting plots by lineshttp://ask.sagemath.org/question/38845/connecting-plots-by-lines/There are 2 plots in a graphics_array (e.g. sin and cos). How do I "connect" these plots with connecting lines (e.g. a dashed line at angle=pi)?Chris_Mon, 18 Sep 2017 08:21:55 -0500http://ask.sagemath.org/question/38845/plot sage Graphics() from jupyter notebok in CoCalchttp://ask.sagemath.org/question/38759/plot-sage-graphics-from-jupyter-notebok-in-cocalc/I want to use sage as a python library from jupyter notebok in CoCalc. I have a problem with Sage plotting:
from sage.all import *
var('x')
plot(sin(x)).show()
This code outputs "Graphics object consisting of 1 graphics primitive".
Pyplot plotting works fine.
There are a number of old posts with the similar problem ( ex. https://ask.sagemath.org/question/10988/in-line-graphics-for-sage-in-ipython-notebook/), some of them recommend changing matplotlib backend with %matplotlib inline which does not help.
Is there a way to output sage Graphics() inline without using pyplot?ADuC812Fri, 08 Sep 2017 07:24:35 -0500http://ask.sagemath.org/question/38759/