partially solved : Works in jmol trough Sage CLI
3D plot remains blank in SageMath in Jupyter Notebook
Edit: This problem still remains unsolved, I have tried to even boot into a different OS (Debian instead of Kali) (not using anaconda, will (hopefully) get more time to try that)
As the title describes and illustrated by this screenshot:
Instead of the expected 3D plot, just a white plain background with a question mark in it, that, when clicked, displays a menu like this:
I have now experimented quite a bit on this example (on my system) and… to give an example:
This shows just a black square (while it’s supposed to show a sphere):
sage: u = var('u')
sage: circle = (cos(u), sin(u))
sage: rp = revolution_plot3d
sage: rp(circle, (u, 0, 2*pi), axis=(0, 0),
....: show_curve=True, opacity=0.5).show(aspect_ratio=(1, 1, 1))
The following code is (I guess) a bit better, but still not really "as it should be", or "as expected":
sage: u = var('u')
sage: circle = (cos(u), sin(u))
sage: rp = revolution_plot3d
sage: rp(circle, (u, 0, 2*pi), axis=(0, 0), frame=False,
....: show_curve=True, opacity=0.5).show(aspect_ratio=(1, 1, 1))
(Change: include frame=False
somewhere in the last line).
Inspiration
I am trying to recreate this 3D plot from the SageMath documentation:
Info/Logs:
-
SageMath version:
SageMath version 9.2, Release Date: 2020-10-24
-
OS: Kali Linux
-
SageMath installed via
apt
:sudo apt-get install sagemath
I do not need to "get" this solved anytime soon, Right now I am mostly doing matrix operations, and such. so – there is no "hurry" with coming up with a solution here! It would just be a [plus+] to be able to do as the problem describe, but it is not necessary.
Any help is greatly appreciated!
Thanks!
4
Answers
MAJOR UPDATE:
To not introduce false hope to the future readers: I have NOT solved it in Jupyter notebook.
But
I have (probably) fixed it with a viewer, my system had Jmol pre installed; (probably because I liked it before, and did some exercises with it, as in Matlab)
The (partial) solution:
But here is the thing, when I access a SAGE terminal (bash ->
sage
) and for example, plotting something that normally would just result in either white - or a black screen in Jupyter whatever I tried to do to make it work;It opens up a jmol window (the, actual application - Jmol)
and plots it.
I did not know it was this easy to get Jmol and sage math to work together (a actual fact; I did not even know this was possible.
Screenshots
here are a few screenshots (Jupyter - black screen, and the exact same code - but run from
Sage Terminal
Same code, but in Sage terminal:
(Identical results) (Which, was for me impossible, even at times where I could (In Jupyter) (ugly)-plot it, it didn't show the expected results, (colors were a bit distorted, and the form had very little in common with the actual plot Sage Docs was showing)
To be honest, I think - I like this more, even if Jupyter would've got to work (maybe some time in the future) This - jmol application has some really neat properties, (color, axis's, and animations (rotation) and other stuff) I did really not know this at all; In Jupyter one maybe could rotate it with the mouse and zoom in, but not really change color, easily - (Not saying this is more expected result, but In my opinion - in my scenario - This was one, (*)good workaround, If not a actual solution, (In my case I will continue this way, it's flawless)
Hopefully this is helpful for someone in the future!
The problem could have to do with the threejs package in Debian that came for the particular version of Sage you got.
You might have better luck installing via Conda or from binaries.
For reference, here is a list of similar reports (including the present one):
Like the OP (original poster), I had the same error with show3d() in a Jupyter notebook under SageMath 9.6. I was not using JMOL. In SageMath 9.7, compiled from source under Ubunto 20.10 in WSL2 on a Windows 10 system, an attempt to use show3d() in a Jupyter notebook, for example
resulted in the following error.
(reformatted for typographical clarity.)
My workaround was to copy the source from $HOME/sage/sage-9.7/src/sage/ext_data/threejs to $HOME/sage/local/lib/sage/ext_data/threejs.
This is not entirely satisfactory as the directory naming suggests that the installation of threejs did not proceed as intended. I may take this up with the SageMath development list.
Adding another answer because this is both quite awhile ago but also, a quite different solution
by adding
Frame=False
, works flawlessly and to be sure this really, works I have tested this on numerous previous problems I had previously and it seems to work, I do not know for sure what this is about but, at least it worksI also experimented a bit with
opacity=1