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.Wed, 20 Mar 2019 17:29:32 -0500fill 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/Specify heights in Poset.plothttp://ask.sagemath.org/question/37756/specify-heights-in-posetplot/ Hi, I'm relatively new to Python and SAGE so please make it simple :)
Basically, I work with posets that are not ranked and I want to plot their Hasse Diagram. For the moment, I use Poset.plot() to display it but I can change to hasse.diagram().plot() if necessary.
My problem is the following : The posets that I work with come with an extra function that associate to every set an integer. Is there a way to use this function to specify the heights of the sets in my plot and not the default one ?
Thank you MthGThu, 01 Jun 2017 04:01:19 -0500http://ask.sagemath.org/question/37756/frozenset error when plotting polytopes: bug?http://ask.sagemath.org/question/10979/frozenset-error-when-plotting-polytopes-bug/I am having trouble understanding an error I get, when i try the following:
ngon=polytopes.regular_polygon(122).dilation(18.1)
ngon.plot()
It says: `KeyError: (frozenset([60]), frozenset([60]))` The following works:
ngon=polytopes.regular_polygon(122).dilation(17.9)
ngon.plot()
What is going on? Is this a bug?mfSun, 02 Feb 2014 00:57:31 -0600http://ask.sagemath.org/question/10979/How can I display a plot from a script?http://ask.sagemath.org/question/37719/how-can-i-display-a-plot-from-a-script/If I type
plot(x^2, (x,-2,2))
in sage, I get the expected plot, displayed as a png file by my default image viewer. If instead I put the line
plot(x^2, (x,-2,2)).show()
in a file test.sage and run
sage test.sage
from the command line, I get
Graphics object consisting of 1 graphics primitive
typed on the command line, but no displayed plot.
How do I display a plot from a script?
millermjSat, 27 May 2017 13:37:44 -0500http://ask.sagemath.org/question/37719/How to draw x^2-3*y^2=4 2d plot ?http://ask.sagemath.org/question/37373/how-to-draw-x2-3y24-2d-plot/It shows error, when I use 'y' variable, and says it is not defined.
So only plots of the form y=f(x) are allowed. How do I overcome this limitation in plotting?
And also how are 2d plots converted to 3D. I know how to do it. But how is it possible to make a 3d plot of a curve say, sin , as it is inherently in 2 dimensions.screened00Sun, 23 Apr 2017 11:05:08 -0500http://ask.sagemath.org/question/37373/ATAN2 AssertionError while plotting complex squareroot functionhttp://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 -0500http://ask.sagemath.org/question/34735/