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.Tue, 11 Jan 2022 12:21:15 +0100SageMath plot: Axis label only partly in LaTeX style. Why?https://ask.sagemath.org/question/60622/sagemath-plot-axis-label-only-partly-in-latex-style-why/For bigger scripts it makes sense to define functions outside of the interact def function. Here it is the function g(), which is defined before the def function. I'd like to use this function name as argument for both plot() and as argument for setting the label of the y-axis.
- This works fine as plot argument: `plot( g(a,x), ... )`
- For the y-axis I can use g() and get the correct expression, but its shown in bold.
How can I manage to get the italic latex style for this y-axis label?
Remark: The usual way to set the label of the y-axis ( '$a*x^3$' )
works well, but this is by far not as flexible as using ( eval('g()') ), because g can be changed.
Do you have any hint, how `eval('g()')` in `p.axes_labels` can be handled in a way, that the y-axis also has a latex style font?
Here is a working minimal code exmple:
var('a, x')
g(a,x) = a*x^3
@interact
def _(a=slider([-5..5], default=2, label='Param a: ')):
p = plot(g(a,x),(x,-3,3), color='purple')
# p.axes_labels([ '$x$', '$a*x^3$' ])
p.axes_labels([ '$x$', eval('g()') ])beTue, 11 Jan 2022 12:21:15 +0100https://ask.sagemath.org/question/60622/Make interact window biggerhttps://ask.sagemath.org/question/57581/make-interact-window-bigger/ When I use @interact for a dynamic plot, either the controls are cut off on top or the plot is cut off on bottom. Is there any way to make the interact window taller?cybervigilanteWed, 16 Jun 2021 05:28:45 +0200https://ask.sagemath.org/question/57581/interact variable not foundhttps://ask.sagemath.org/question/54668/interact-variable-not-found/ I keep getting ValueError: Variable 'h' not found when I try to plot an interact:
f = (x-h)^2 - 4*a*(y-k)
Parabola = solve(f,y)[0].rhs()
print(Parabola)
@interact
def _(h=slider(-5,5,default=1), a=slider(-5,5,default=1), k=slider(-5,5,default=1)):
show(plot(Parabola,x,-5,5))
It even creates the sliders but the plot can't see h. What am I doing wrong?
print(Parabola)![image description](/upfiles/1607889762688566.png)
cybervigilanteSun, 13 Dec 2020 21:05:35 +0100https://ask.sagemath.org/question/54668/lengthen interact window or move controls to sidehttps://ask.sagemath.org/question/54500/lengthen-interact-window-or-move-controls-to-side/Is there any way I can lengthen the Interact window or move the controls to the side? When I have more than two controls it cuts off the function plot at the bottom so it's hard to see the effect.
@interact
def _(a=(1,7),b=(-5,5),c=(-10,10),d=(-6,6)):
f(x) = a*(x+d)^2 +c*(x) + b
show(plot(f,-6,5,aspect_ratio=.2,ymax=100) + text("f(x) = a*(x+d)^2 +c*(x+e) + b",(10,100)))
![image description](/upfiles/16068541695735529.png)cybervigilanteTue, 01 Dec 2020 21:13:26 +0100https://ask.sagemath.org/question/54500/How to fix interact flickering of a ranged plot?https://ask.sagemath.org/question/35201/how-to-fix-interact-flickering-of-a-ranged-plot/ I have this code
var('k');f(x) = sum(1/k,k,1,floor(x))
@interact
def _(n=slider(20,200,step_size=1)):
p1 = plot(f(x),(x,1,n),fill=log(x),fillcolor="lightgreen",alpha=0.2,legend_label='$f(x)=\sum_{k=1}^{\lfloor x \\rfloor}\\frac{1}{k}$')
p2 = plot(log(x),(x,1,n),fill='axis',fillcolor="lightgrey",legend_label="$g(x)=\log (x)$")
show(p1 + p2)
but this have the problem that when I change the value of the slider the graph flicker instead of a smooth change. It is a way to fix this or change this behavior? Thank you.MasacrosoThu, 20 Oct 2016 09:05:15 +0200https://ask.sagemath.org/question/35201/Fast show()? (for cached plots for @interact)https://ask.sagemath.org/question/8087/fast-show-for-cached-plots-for-interact/Hello,
I need a fast (no noticeable delay) version of the following:
@interact
def _(a=(0,10)):
time show(plot(lambda x:sin(a*x),plot_points=10000))
Time: CPU 2.65 s, Wall: 2.72 s
<br/>
I can cache the plots, but showing them takes half a second:
@cached_function
def p(a):
return plot(lambda x:sin(a*x),plot_points=10000)
for i in range(101):
p(N(i/10))
@interact
def _(a=(0..100)):
time p2=p(N(a/10))
time show(p2)
Time: CPU 0.00 s, Wall: 0.00 s
Time: CPU 0.42 s, Wall: 0.43 s
<br/>
Is there a faster way?
Thanks!
chaeslocWed, 20 Apr 2011 11:09:16 +0200https://ask.sagemath.org/question/8087/