Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to get Sage 8.0 to plot matplotlib plots inline on a Jupyter notebook?

If I start Sage 8.0 notebook using the jupyter notebook (sage -n jupyter), and run either of the following code in a cell:

%matplotlib inline
import matplotlib.pyplot as plt

x = [1,2,3]
y = [-1,1,0]
plt.plot(x, y, 'bo-')
plt.show()

or

%matplotlib inline
import matplotlib.pyplot as plt

x = [1,2,3]
y = [-1,1,0]
plt.plot(x, y, 'bo-')
plt.savefig('xxx.png')

Both do not result in a plot. Instead the output is:

π™΅πš’πšπšžπš›πšŽ(𝟺𝟹𝟸𝚑𝟸𝟾𝟾)

On the other hand, if I run Sage 8.0 using the old notebook (sage -n sagenb), this code results in a plot in a separate windows:

import matplotlib.pyplot as plt

x = [1,2,3]
y = [-1,1,0]
plt.plot(x, y, 'bo-')
plt.show()

While this code results in a plot inline:

import matplotlib.pyplot as plt

x = [1,2,3]
y = [-1,1,0]
plt.plot(x, y, 'bo-')
plt.savefig('xxx.png')

How do I get a matplotlib plot to appear inline when I am using Sage in a Jupyter notebook? I've already installed the tk and tk-dev libraries as mentioned in the installation guide and reinstalled the matplotlib library using sage -f matplotlib after running export export SAGE_MATPLOTLIB_GUI=yes.

How to get Sage 8.0 to plot matplotlib plots inline on a Jupyter notebook?

If I start Sage 8.0 notebook using the jupyter notebook (sage -n jupyter), and run either of the following code in a cell:

%matplotlib inline
import matplotlib.pyplot as plt

x = [1,2,3]
y = [-1,1,0]
plt.plot(x, y, 'bo-')
plt.show()

or

%matplotlib inline
import matplotlib.pyplot as plt

x = [1,2,3]
y = [-1,1,0]
plt.plot(x, y, 'bo-')
plt.savefig('xxx.png')

Both do not result in a plot. Instead the output is:

π™΅πš’πšπšžπš›πšŽ(𝟺𝟹𝟸𝚑𝟸𝟾𝟾)

On the other hand, if I run Sage 8.0 using the old notebook (sage -n sagenb), this code results in a plot in a separate windows:

import matplotlib.pyplot as plt

x = [1,2,3]
y = [-1,1,0]
plt.plot(x, y, 'bo-')
plt.show()

While this code results in a plot inline:

import matplotlib.pyplot as plt

x = [1,2,3]
y = [-1,1,0]
plt.plot(x, y, 'bo-')
plt.savefig('xxx.png')

How do I get a matplotlib plot to appear inline when I am using Sage in a Jupyter notebook? I've already installed the tk and tk-dev libraries as mentioned in the installation guide and reinstalled the matplotlib library using sage -f matplotlib after running export export SAGE_MATPLOTLIB_GUI=yes.

How to get Sage 8.0 to plot matplotlib plots inline on a Jupyter notebook?

If I start Sage 8.0 notebook using the jupyter notebook (sage -n jupyter), and run either of the following code in a cell:

%matplotlib inline
import matplotlib.pyplot as plt

x = [1,2,3]
y = [-1,1,0]
plt.plot(x, y, 'bo-')
plt.show()

or

%matplotlib inline
import matplotlib.pyplot as plt

x = [1,2,3]
y = [-1,1,0]
plt.plot(x, y, 'bo-')
plt.savefig('xxx.png')

Both do not result in a plot. Instead the output is:

π™΅πš’πšπšžπš›πšŽ(𝟺𝟹𝟸𝚑𝟸𝟾𝟾)

On the other hand, if I run Sage 8.0 using the old notebook (sage -n sagenb), this code results in a plot in a separate windows:

import matplotlib.pyplot as plt

x = [1,2,3]
y = [-1,1,0]
plt.plot(x, y, 'bo-')
plt.show()

While this code results in a plot inline:

import matplotlib.pyplot as plt

x = [1,2,3]
y = [-1,1,0]
plt.plot(x, y, 'bo-')
plt.savefig('xxx.png')

How do I get a matplotlib plot to appear inline when I am using Sage in a Jupyter notebook? I've already installed the tk and tk-dev libraries as mentioned in the installation guide and reinstalled the matplotlib library using sage -f matplotlib after running export export SAGE_MATPLOTLIB_GUI=yes.

How to get Sage 8.0 to plot matplotlib plots inline on a Jupyter notebook?

If I start Sage 8.0 notebook using the jupyter notebook (sage -n jupyter), and run either of the following code in a cell:

%matplotlib inline
import matplotlib.pyplot as plt

x = [1,2,3]
y = [-1,1,0]
plt.plot(x, y, 'bo-')
plt.show()

or

%matplotlib inline
import matplotlib.pyplot as plt

x = [1,2,3]
y = [-1,1,0]
plt.plot(x, y, 'bo-')
plt.savefig('xxx.png')

Both do not result in a plot. Instead the output is:

π™΅πš’πšπšžπš›πšŽ(𝟺𝟹𝟸𝚑𝟸𝟾𝟾)

On the other hand, if I run Sage 8.0 using the old notebook (sage -n sagenb), this code results in a plot in a separate windows:

import matplotlib.pyplot as plt

x = [1,2,3]
y = [-1,1,0]
plt.plot(x, y, 'bo-')
plt.show()

While this code results in a plot inline:

import matplotlib.pyplot as plt

x = [1,2,3]
y = [-1,1,0]
plt.plot(x, y, 'bo-')
plt.savefig('xxx.png')

How do I get a matplotlib plot to appear inline when I am using Sage in a Jupyter notebook? I've already installed the tk and tk-dev libraries as mentioned in the installation guide and reinstalled the matplotlib library using sage -f matplotlib after running export export SAGE_MATPLOTLIB_GUI=yes.

How to get Sage 8.0 to plot matplotlib plots inline and typeset expressions on a Jupyter notebook?

If I start Sage 8.0 notebook using the jupyter notebook (sage -n jupyter), and run either of the following code in a cell:code:

%matplotlib inline
from numpy import arange, sin, pi

import matplotlib.pyplot as plt

X = arange(0.0, 2*pi, 0.01)

plt.plot(X, sin(X))

plt.show()

x = [1,2,3]
y = [-1,1,0]
plt.plot(x, y, 'bo-')
plt.show()
+ 1

orThe plot displays inline but the expression $x+1$ is not typeset.

If I run the following code:

%matplotlib inline
%display typeset


from numpy import arange, sin, pi

import matplotlib.pyplot as plt

X = arange(0.0, 2*pi, 0.01)

plt.plot(X, sin(X))

plt.show()

x = [1,2,3]
y = [-1,1,0]
plt.plot(x, y, 'bo-')
plt.savefig('xxx.png')
+ 1

Both do Then, the plot does not result in a plot. Instead the output is:display inline. It shows:

π™΅πš’πšπšžπš›πšŽ(𝟺𝟹𝟸𝚑𝟸𝟾𝟾)

On However, the other hand, if I run Sage 8.0 using the old notebook (sage -n sagenb), this code results expression $x+1$ is in a plot in a separate windows:typeset.

import matplotlib.pyplot as plt

x = [1,2,3]
y = [-1,1,0]
plt.plot(x, y, 'bo-')
plt.show()

While this code results in a plot inline:

import matplotlib.pyplot as plt

x = [1,2,3]
y = [-1,1,0]
plt.plot(x, y, 'bo-')
plt.savefig('xxx.png')

How do can I get a matplotlib plot to appear inline when I am using Sage in a Jupyter notebook? I've already installed the tk and tk-dev libraries as mentioned in the installation guide and reinstalled have both the matplotlib library using sage -f matplotlib after running export export SAGE_MATPLOTLIB_GUI=yes.plots display inline and expressions typeset?

How to get Sage 8.0 to plot matplotlib plots inline and typeset expressions on a Jupyter notebook?

If I start Sage 8.0 notebook using the jupyter notebook (sage -n jupyter), and the following code:

from numpy import arange, sin, pi

import matplotlib.pyplot as plt

X = arange(0.0, 2*pi, 0.01)

plt.plot(X, sin(X))

plt.show()

x + 1

The plot displays inline but the expression $x+1$ is not typeset.

If I run the following code:

%display typeset


from numpy import arange, sin, pi

import matplotlib.pyplot as plt

X = arange(0.0, 2*pi, 0.01)

plt.plot(X, sin(X))

plt.show()

x + 1

Then, the plot does not display inline. It shows:

π™΅πš’πšπšžπš›πšŽ(𝟺𝟹𝟸𝚑𝟸𝟾𝟾)

However, the expression $x+1$ is in typeset.

How can I have both the matplotlib plots display inline and expressions typeset?