Ask Your Question

JC's profile - activity

2021-09-06 18:11:59 +0200 received badge  Popular Question (source)
2021-08-08 17:52:23 +0200 asked a question enriched contour plot

enriched contour plot He there, I would like to make a contour plot for a function of two variables that is enriched wit

2021-03-26 09:23:22 +0200 received badge  Notable Question (source)
2020-11-09 18:49:20 +0200 received badge  Popular Question (source)
2020-08-17 06:45:42 +0200 received badge  Popular Question (source)
2020-07-14 23:44:35 +0200 received badge  Nice Question (source)
2020-07-03 14:33:08 +0200 asked a question I broke jupyter (again)

I was trying to install some dark themes, so I ran

$ sage --pip install jupyterthemes

followed by

$ sage --pip install --upgrade jupyterthemes

as suggested here.

Then, when I launch

$ sage -n jupyter

the server seems to open correctly, but when trying to open an .ìpynb file, I get

500: internet server error

Sage itself is running, from the command line everything is o.k. More than that, running

$ sage -n jupyterlab

gives no problem at all: I can still run my notebooks.

Running sage 9.1 on Ubuntu 18.04. At some point I installed hide_code as per this thread. Perhaps my problem comes from some broken dependencies?

2020-07-02 18:22:06 +0200 received badge  Nice Question (source)
2020-07-02 18:22:03 +0200 received badge  Teacher (source)
2020-07-02 18:22:03 +0200 received badge  Self-Learner (source)
2020-07-02 18:15:39 +0200 answered a question nbextensions in jupyter from sagemath

I got it! Must run sage -jupyter contrib nbextension install --user Solution from this post

2020-06-30 21:16:42 +0200 asked a question nbextensions in jupyter from sagemath

Hello to everyone,

I am trying to install nbextensions for jupyter. I always run jupyter from sage with sage -n jupyter. I just upgraded (builr) to sage 9.1, then did sage -pip install jupyter_contrib_nbextensions. I got no error for that installation, but then when I launched sage -n jupyter I was expecting to see that extra tab for the extensions. It is not there, though.

Running on a unbutu18.04 machine.

Thanks! JC

2020-06-03 22:21:06 +0200 commented answer From Jupyter to one cell server

Thanks Emmanuel, I played around a with PreTeXT a little bit, and from what I understand, it is more complex, although in principle feasible. But then again : in principle that should not be very hard to write a script that takes as input one .html produced by jupyter and turn avery cell code into a celle that is to be interpreted by a one-cell server.

2020-06-02 21:16:00 +0200 commented answer From Jupyter to one cell server

Thanks for taking the time. I am aware of Binder and the like, but it is not what I want : the goal would be to have everything running with one click, without leaving Moodle, without having to rely on the local machine, nor an external server (we actually may have a jupyter hub server working). The question is more like : is there a way to quickly turn a code cell into a cell to be interpreted by the one-cell server? Thanks!

2020-06-02 16:49:21 +0200 asked a question From Jupyter to one cell server

Hi there,

A long time ago I learned how to use the one-cell server. At that moment I was creating simple .html files for my students, so they could execute some code and learn a bit of Sage.

Nowadays this seems inefficient, instead of writing .html file it seems reasonable to write everything in a jupyter notebook. As I want to embed the files into a Moodle page, and want the cells to be executable therein, or by downloading an html file, without having Sage installed in the local machine, I thought I could try to turn each code cell of the jupyter notebook into a cell pointing to the one-cell server. Is it possible to do this efficiently? Can I somehow achieve my goal with Cocalc?


2020-05-09 16:22:19 +0200 received badge  Nice Question (source)
2020-05-08 03:41:24 +0200 asked a question SageTeX: formatting matrices

Hello all,

I would like to have sagetex producing matrices with the columns centered. If was writing this by hand, I would do \begin{bmatrix*}[c] ... \end{bmatrix*}

From my XXX.sout file, I see the result \begin{array}{rrr} ... \end{array}. Is there a way to control this? Either playing at the sage level directly or by controlling sagetex?


2020-05-04 18:24:30 +0200 asked a question Escape characters for LaTeX

I am using SageTeX and LaTeX to produce several variations of an exam, with a script that makes several iterations. I do this:

var('x, y, z')
v = vector([x, y, z])
a = vector([1, -2, -1])

These will change from one iteration to the next.

sortie = str(latex(a.dot_product(v)))

This leads to

x - 2 \\, y - z

which is correct, and I would like to turn into

\bbm{x} -2 \\, \bbm{y} - \bbm{z}

for the LaTeX processing so that x, y and z are shown like vectors.


2020-03-19 02:47:51 +0200 commented answer SageTex, sage, version conflict?

Hello @EmmanuelCharpentier Thanks for taking the time. I am sorry your answer is a little bit obscure to me : I do not know how to perform the steps you suggest.

Would it be possible to add some feature so that upgrading sage does not break sagetex?

2020-03-19 02:37:41 +0200 answered a question How to install hide_code in SageMath?

@Sebastien I tried what you mention.

$ ./sage -pip install jupyterlab
$ ./sage -pip install RISE

Up to that point everything was kind of ok

Then I did

$ ./sage -pip install hide_code

(not hide-code) and that's where everything got screwed.

I am uncompressing the binaries again. But then I have two questions

  1. How to make jupyter to start in my /user directory instead of ../sage-9.0-Ubuntu_18.04-x86_64/SageMath$
  2. How do I install the hide_codeextension, or something allowing to obtain the same effect : to teach mathematics it is often useful to show only the result (perhaps a figure), and ignore the code. How to do this using RISE? I tried the instructions here but that failed.
2020-03-19 01:10:14 +0200 commented question How to install hide_code in SageMath?

Hello @Sebastien No, Sage 9.0 works fine. I did not install the hide-code extension yet, will tray later today.

2020-03-17 02:46:33 +0200 asked a question How to install hide_code in SageMath?

Hi all,

I have sage 8.1 installed on Ubuntu 18.04. It works fine from the terminal, the deprecated notebook seems to work correctly as well. Hoewever when I launch sage -n jupyter and try to open/create an ipynb file, I get Error 500 : Internal Server Error.

Below, what I obtain from the terminal.

I certainly broke something during the weekend, I was trying to get the hide_code extension to work, and I clearly did something that I should not. I don't know precisely what, but I tried to intall jupyter lab, and many other manipulations.

Any suggestion?

Edit 1 I edited, as per Sébastien's first answer.

Edit 2 My question deviated towards the installation of hide_code for jupyter. @Sebastien answered, the procedure works fine!

Thanks in advance!

| SageMath version 8.1, Release Date: 2017-12-07 │

│ Type "notebook()" for the browser-based notebook interface. │

│ Type "help()" for help. │

Please wait while the Sage Jupyter Notebook server starts... File "/home/jcb/.local/lib/python2.7/site-packages/hide_code/", line 9, in <module> from hide_code.hide_code_html_exporter import HideCodeHTMLExporter ImportError: No module named hide_code_html_exporter

2020-02-24 03:14:11 +0200 asked a question Gridlines, ticks and the like in polar coordinates

Hello to everyone,

I'd like to produce a polar plot with thecorresponding "polar grid" in it (i.e. the lines corresponding to $\theta = $ constant, and the circles $r = $ constant appearing. Also, I would like to have something like the tick markers. I guess I could do something like this manually, but seems very unelegant... An idea?


2020-02-18 03:45:17 +0200 asked a question Legend_fonts in list of plots

Hello there,

I want to make an array of plots, and I need the font size for the legends to be reduced. I tried the code below and some variants.I really don't see what is wrng, when I try the ().set_legend_options(font_size = 8) on a single curve, everything works fine. I tried doing this while running through a list, but did not work.

C=[2.5, 1.7, 1, 0.7, 0.5, 0.2, 0, -0.2, -0.5, -0.8, -1, -2] # The values for c
Curves = [polar_plot(1+c*sin(t),0,t,2*pi, 
                     legend_label = '%s'%c.n(digits=2)).set_legend_options(font_size = 8) for c in C]
Array = graphics_array(((Curves[0],Curves[2], Curves[2], Curves[3]),
                     (Curves[4],Curves[5], Curves[6], Curves[7]),
                     (Curves[8],Curves[9], Curves[10], Curves[11])))  = 9)

Thanks in advance!

2019-08-30 01:54:19 +0200 asked a question SageTex, sage, version conflict?

Hello to everyone,

I am trying to use sagetex in my ubuntu18.094 machine. I use the file from this manual. I call my file Test.tex

PdfLatex does its job. I have a Test.sagetex.sagefile in my folder. When I run, at the same folder, from a terminal sage Test.sagetex.sage I get the following error

Traceback (most recent call last):

File "", line 9, in <module>

_st_ = sagetex.SageTeXProcessor('Test', version='2015/08/26 v3.0-92d9f7a', version_check=True)

File "... Programs/sage-8.1/local/lib/python2.7/site-packages/", line 76, in __init__

raise VersionError(errstr)

sagetex.VersionError: versions of .sty and .py files do not match.

Test.sagetex.sage was generated by sagetex.sty version "2015/08/26 v3.0-92d9f7a", but

is being processed by version "2019/01/09 v3.2".

Please make sure that TeX is using the sagetex.sty

from your current version of Sage; see...

I built sage from the source code, at some point, then I upgraded with sage update. I now have sage 8.8 but still a folder sage-8.1

I installed sagetex from the repos.

Anyone a suggestion?


2019-08-19 22:25:07 +0200 asked a question RISE in Jupyter

Hello to eveyone,

I wnated to install and use RISE to make Jupyter presentations from Sagemath, but something went wrong. I did it once, and it works with one laptop, but when trying to do the same with anoter (freshly installed Ubuntu 18.04), I ran in trouble.

I compiled sage-8.8 from the source.

I got the instructions to install RISE from here,(changing to lower case does not affect the result) and also here.

  • When i ltry to execute ~.../sage-8.8$ ./sage -pip install RISE I get an error that begins with :

pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available....

  • On the other hand I followed these instructions (option 2) to add sage as a command. Then when I do

sage -pip install RISE

from a terminal (in arbitray directory), I get

sage-run received unknown option: -pip

usage: sage [options]

Try 'sage -h' for more information

Note however that sage -n jupyter launches Jupyter correctly.


2019-05-22 22:57:12 +0200 commented answer Discontinuous surface color by z-level

Great! That region trick is awesome!

2019-05-22 22:55:41 +0200 received badge  Scholar (source)
2019-05-16 03:21:29 +0200 received badge  Editor (source)
2019-05-16 03:12:51 +0200 asked a question Discontinuous surface color by z-level

Hi there, I want to plot a surface $z=f(x,y)$ together with the level curves (side by side). I know how to doi it when $f$ is continuous, or even bounded, but I run in trouble for uglier functions. Here are two examples (in CoCalC : a few things need to be adapted to use Jupyter) : the first works

h(x,y)= x*y^2/(x^2+y^4)
cm = colormaps.Blues
def c(x,y):
    return 0.6+x*y^2/(x^2+y^4+0.005)# Colorier ceci pose des problèmes, à cause de la singularité.
S=plot3d(h,(x,-1,1),(y,-1,1),color = (c,cm), opacity=1, mesh=1)
C=contour_plot(h, (x,-1, 1), (y,-1, 1),cmap='Blues',linestyles='solid', colorbar=True)

While the second, below, does not work as I would like to

h(x,y)= y/(x^2+y^2)
cm = colormaps.Spectral
def c(x,y):
    return float(y/(x^2 + y^2+0.005))# Colorier ceci pose des problèmes, à cause de la singularité.
S=plot3d(h,(x,-1,1),(y,-1,1),color = (c,cm), opacity=1, mesh=1)
show(S, frame_aspect_ratio=[20,20,1])
C=contour_plot(h,(x,-1.5,1.5),(y,-1.5,1.5), cmap = "Spectral", 
               contours = [-2,-1, -0.5,-0.25,0,0.25,0.5,1,2], colorbar = True, 
               axes = True, 
               labels = True, label_colors='black', 
               label_inline=True, label_fontsize=8, 
               gridlines = True, axes_labels=['$x$','$y$'])

I tried a few things, among other, what can be found (old post), but the discontinuity seems to cause some problems.