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.Sun, 13 Feb 2022 12:44:24 +0100Why specifying `stylesheet` parameter in plot function causes error?https://ask.sagemath.org/question/61081/why-specifying-stylesheet-parameter-in-plot-function-causes-error/I'm disappointed by how the default plot style looks, so I decided to find some fancier stylesheet.
The [official documentation](https://doc.sagemath.org/html/en/reference/plotting/sage/plot/plot.html) says:
> MATPLOTLIB STYLE SHEET OPTION:
>
> `stylesheet` - (Default: classic) Support for loading a full matplotlib style sheet.
> Any style sheet listed in matplotlib.pyplot.style.available is acceptable.
> If a non-existing style is provided the default classic is applied.
When I try it with a simple example, I get
plot(sin, stylesheet="ggplot")
...
RuntimeError: Error in line(): option 'stylesheet' not valid.
However I found that this alternative works:
plot(sin).show(stylesheet="ggplot")
This is ugly, because I use IPython CLI and want to be able to show the plot by this syntax
p = plot(sin)
p
without typing `.show()`.
Moreover, I'd like to configure my `.sage/init.sage` file so that the 'ggplot' stylesheet is used by default:
# .sage/init.sage
plot.options["stylesheet"] = "ggplot"
This doesn't work though, for sage substitutes this option into `line()` function which appears to have no such option.
**Questions:**
1. Is this a bug, or a mistake in (my understanding of) the documentation? Should it be reported and if yes, where is the best place to do it?
2. How do I achieve custom plotting style by default (perhaps by some setting in the `init.sage` file)?
I'm using SageMath version 9.5, Release Date: 2022-01-30 with Python 3.10.2, all downloaded from ArchLinux official repos.SageUserNickSun, 13 Feb 2022 12:44:24 +0100https://ask.sagemath.org/question/61081/Does Sage have a plain math expression editor, without any calculation performed?https://ask.sagemath.org/question/35331/does-sage-have-a-plain-math-expression-editor-without-any-calculation-performed/Is there a way to edit an expression in a pretty, classical, math style without declaring variables and without evaluating?
In Mathematica we can write whatever we want using some keystroke shortcuts and it looks just as if it were hand-written. We can keep these notes in a file and re-use them (visualize, modify...) later on. The powerful feature is that we can copy and paste any part of such notes into a notebook and get it evaluated in the most straightforward way.
Can we do this in Sage?
Michel PoquerusseTue, 01 Nov 2016 21:56:19 +0100https://ask.sagemath.org/question/35331/[style] Choose between multiple inheritancehttps://ask.sagemath.org/question/10692/style-choose-between-multiple-inheritance/Dear Sage people,
I want to create a new (mathematical) object that sometimes is an Expression and sometimes a SymbolicFunction, depending on the arguments. You can think of this for example like $f(a, b, t) = \int_0^t a^b e^{-x^2} dx$. For special values of $t$ I would like to see it as an Expression ($t=0$ or $t=\infty$), but in all other cases I want it to be a BuiltinFunction (or something alike).
In Sage I can do something like:
class MyObjectExpression(Expression):
def __init__(self, a, b, t):
Expression.__init__(self, integral(a**b*e**(-x**2), x, 0, t))
# More (override) stuff below
class MyObjectFunction(BuiltinFunction):
def __init__(self, a, b, t):
BuiltinFunction.__init__(self, 'f(a,b,t)', nargs=1)
# More (override) stuff below
def MyObject(a, b, t):
if t == 0 or t == infty:
return MyObjectExpression(a, b, t)
else:
return MyObjectFunction(a, b, t)
Is it possible to combine these three things into one class? So I want to create a class which is sometimes an Expression and sometimes an much more abstract class, is this possible?
Best,
Noud
**Edit:**
What I actually want to do is programming Askey-Wilson polynomials and give them extra options, like a three term recurrence relation. But this depends on $n$. I already programmed this.
class Askey_Wilson(SageObject):
def __init__(self, SR, n, z, a, b, c, d, q):
self.n = n
self.z = z
self.q = q
self.a = a
self.b = b
self.c = c
self.d = d
self.param = [a, b, c, d]
if self.n in ZZ:
self.I = self.evaluate()
else:
self.I = var('askey_wilson')
def __repr__(self):
return 'p_%i(%s;%s,%s,%s,%s|%s)' % (
self.n, self.z, self.a, self.b, self.c, self.d, self.q
)
def evaluate(self):
n, q, z, a, b, c, d = [self.n, self.q, self.z] + self.param
lc = qPochhammerSymbol(SR, [a*b, a*c, a*d], q, n) / a**n
poly = BasicHypergeometricSeries(SR,
[q**(-n), a*b*c*d*q**(n-1), a*z, a*z**(-1)],
[a*b, a*c, a*d], q, q)
return lc*poly
def three_term_recurrence(self):
A, B, C = 0, 0, 0
# compute three term recurrence relation
return A, B, C
But now every time I want to know the explicit value of the Askey-Wilson polynomials I have to call askey_wilson.I. I want to get rid of the I.NoudSun, 03 Nov 2013 14:22:42 +0100https://ask.sagemath.org/question/10692/How to mention point style in plot2d option?https://ask.sagemath.org/question/7483/how-to-mention-point-style-in-plot2d-option/How to mention point style in plot2d option?ajitSun, 21 Jul 2013 08:40:04 +0200https://ask.sagemath.org/question/7483/