Use test_display instead.
This notebook has not been removed only because some links on Sage Trac may refer to it...
version()
'SageMath version 9.6.beta5, Release Date: 2022-03-12'
%display latex
sin(x^2)
type(x)
set([1,2])
RubiksCube()
import matplotlib.pyplot as plt
plt.plot([1, 2, 3, 4])
plt.ylabel('some numbers')
plt.show()
%display plain
import matplotlib.pyplot as plt
plt.plot([1, 2, 3, 4])
plt.ylabel('some numbers')
plt.show()
_repr_latex_
¶%display plain
s = sin(x^2)
s
sin(x^2)
view(s)
s._latex_()
'\\sin\\left(x^{2}\\right)'
class A(SageObject):
def __init__(self, data):
self._data = data
def _repr_latex_(self):
try:
return '$' + self._data._latex_() + '$'
except (AttributeError, NotImplementedError):
return None # if None is returned, plain text is used
A(sin(x^2))
s = A(sin(x^2))
s
print(s)
<__main__.A object at 0x7f8b7ef4aee0>
[s, s, s]
[<__main__.A object at 0x7f8b7ef4aee0>, <__main__.A object at 0x7f8b7ef4aee0>, <__main__.A object at 0x7f8b7ef4aee0>]
g = plot(sin(x^2))
print(A(g))
<__main__.A object at 0x7f8b7ef62bb0>
s0 = A(None)
s0
<__main__.A object at 0x7f8b7db47820>
%display latex
#%display plain
sin(x^2)
NB: %matplotlib notebook
is not supported by Jupyterlab; one should use %matplotlib widget
(which requires the Python package ipympl
).
Workaround proposed at #33469:
sage.repl.display.formatter.IPYTHON_NATIVE_TYPES
import ipywidgets
sage.repl.display.formatter.IPYTHON_NATIVE_TYPES += (ipywidgets.Widget,)
sage.repl.display.formatter.IPYTHON_NATIVE_TYPES
#%matplotlib notebook
%matplotlib widget
import matplotlib.pyplot as plt
plt.plot([1, 2, 3, 4])
plt.ylabel('some numbers')
plt.show()
%display latex
¶@interact
def f(n=10):
print(n)
Interactive function <function f at 0x7f8b7da8d0d0> with 1 widget n: IntSlider(value=10, description='n', ma…
%display latex
sin(x^2)
@interact
def f(n=10):
print(n)
Interactive function <function f at 0x7f8b7dafcf70> with 1 widget n: IntSlider(value=10, description='n', ma…