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/